1

I have a php file that loads a different form based on a identifier passed in with a GET request.

Everything works.... except my Javascript/jQuery. Is there a way to re-load my javascript to get it to work on the form?

Or will I need to something else entirely ? like a template system?

Currently, when the page is being loaded by the browser it is commenting out my Javascript script tag that loads my functions.js file. I'm assuming this is because it is because the code relies on a form and as the form hadn't been loaded yet, some kind of error forces the script to be commented out.

1
  • is your javascript <script> tag after the form, outside of the form? I'm not sure what could be commenting out your Javascript, can you give an example? Commented Mar 6, 2017 at 18:17

1 Answer 1

2

You can rectify your problem in two ways:-

1. Put you complete javascript/jQuery code at the bottom of the page (very last) inside (<script></script>)

Or

2. Wrap your complete code inside $(document).ready(function(){ ...//your code ....});

Note:-

a. If you are trying to include an external javascript/jQuery file which have the custom code,then also include it at the bottom of the current page.

b. Take care that proper jquery library (if needed) will added before your code

Sign up to request clarification or add additional context in comments.

3 Comments

I was already doing number 2, so I additionally did number 1. That get the js to not be commented out. Thanks!
@daredevil1234 glad to help you. :):)
yeah, I'll mark it as soon as stackoverflow lets me. Apparently there is a minimum amount of time that has to go by until I can accept an answer. Never encountered that before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.