JulianJ JulianJ - 7 months ago 34
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>


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.