Why doesn't jquery execute

  • Posted April 25, 2014

I have created Ubuntu 14.04 droplet, and have manualy installed apache, php, and mysql (as described here: I have also transfered my DB’s and web to this new droplet. Now, i cant seem to execute the jquery code properly. eg: I have html: <input type=submit name=SAVE id=SAVE value=“0” style=“display:none;” /></form><div class=button onClick=“document.getElementById(‘SAVE’).click()”>Save</div> and JS: $(“#frm”).submit(function(event) { console.log(‘starting’); event.preventDefault(); var posting = $.post( ‘content_add_proc.php’, $(this).serialize() ); posting.done(function( data ) { alert(data); console.log(data); loadadm(‘content.php’,‘#top03’); }); }); I never get ‘starting’ in the console. Nor any errors for that matter.

howewer if i replace the div with this: <div class=button onClick=“console.log(‘test’);”>Save</div> and click it, i get the ‘test’ in the console so the triggers, but the function doesn’t execute

before you ask, there is the <form id=frm name=frm … > tag

i’ll repeat: it’s only copy paste from one server to another


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

It’s hard to say with out looking at more code. Is the submit handler wrapped in “$(document).ready”? This works for me on 14.04: <br> <br><pre> <br><html> <br> <head> <br> <meta content=“text/html;charset=utf-8” http-equiv=“Content-Type”> <br> <meta content=“utf-8” http-equiv=“encoding”> <br> <script type=“text/javascript” src=“”></script> <br> <script> <br> <br> $(document).ready(function(){ <br> $( “#frm” ).submit(function( event ) { <br> console.log(“Handler for .submit() called.”); <br> }); <br> }); <br> <br> </script> <br> </head> <br> <body> <br>
<br> <form id=“frm” name=“frm”> <br> <input type=submit name=SAVE id=SAVE value=“0” style=“display:none;”/> <br> </form> <br> <br> <div class=button onClick=“document.getElementById(‘SAVE’).click();”>Save</div> <br>
<br> </body> <br></html> <br></pre> <br> <br>As the JavaScript executes in the user’s browser, it really shouldn’t matter what version of Ubuntu the server is running.