Reputation: 1425
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.
Upvotes: 1
Views: 20
Reputation: 72289
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
Upvotes: 2