I have a form with two places that use ajax to submit the information to server.
$("#loading img").ajaxStart(function(){ // this progress bar is used by both ajax submission.
$(this).show();
}).ajaxStop(function(){
$(this).hide();
});
<div id="loading">
<img src="loading4.gif" border="0" />
</div>
$('#countyForm').ajaxForm(options); // Case I: use ajax to submit the form
$('form#carSelect').change(function(){ // Case II: use ajax to submit the field
$.ajax({
...
}
});
});
How can I customize the ajax in jQuery so that I can use different progressbar for different ajax submission.
Say for case I, I use image1 and case II I use image2.
Thank you
Similar jsFiddle Example w/o ajaxForm
Instead of using Ajaxstart and stop, just show the individualized loading image first, then fire the Ajax directly. Ajaxstop fires when all the ajax is done on a page. You want individualized attention.
The ajaxForm plugin allows for a callback function for after the AJAX has fired. Use this to remove your custom animation. Separately bind a click event handler to the form’s submit button to load that custom animation. I haven’t used that plugin, so there may be an easier way.
For the other case, simply load the custom image, call the AJAX and remove the image on success.