Why doesn't jquery execute

April 25, 2014 1.8k views
I have created Ubuntu 14.04 droplet, and have manualy installed apache, php, and mysql (as described here: https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04). 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:
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:
and click it, i get the 'test' in the console so the DIV.click triggers, but the function doesn't execute before you ask, there is the tag i'll repeat: it's only copy paste from one server to another
1 Answer
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:

<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

$( "#frm" ).submit(function( event ) {
console.log("Handler for .submit() called.");


<form id="frm" name="frm">
<input type=submit name=SAVE id=SAVE value="0" style="display:none;"/>

<div class=button onClick="document.getElementById('SAVE').click();">Save</div>


As the JavaScript executes in the user's browser, it really shouldn't matter what version of Ubuntu the server is running.
Have another answer? Share your knowledge.