JulianJ JulianJ - 1 year ago 97
jQuery Question

Why is my jquery loader not working?

I am trying to add a loading gif to some jquery script. I thought I might use this plugin which has worked before but I am trying to figure out why it is not firing when I submit a form. Have I got it in the correct place?

$(document).ready(function() {
$('#post_data').submit(function() {
//I've placed the plugin here
url: 'process.php',
type: 'POST',
dataType: 'html',
data: $(this).serialize(),
success: function(newContent) {
$('#mytable').prepend('<tr>' + newContent + '</tr>');


return false;

The div where I want it to appear.

<div class="center-block" id="spinner"></div>

Answer Source

Did a fiddle for you: https://jsfiddle.net/2Lazd0ez/

Inserted this line:

$('#post_data').submit(function(e) {

The reason being not using preventDefault() and actually submitting the form serverside, instead of through jQuery.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download