javascript - How to show 'Please wait' GIF image on Ajax load -
am using ajax send request web server, show user gif image indicating them wait till request completed.
can please me modify code load gif image on sending request.
jquery(document).submit(function(e){ var create_acct_form = jquery(e.target); if(create_acct_form .is("#createacctform")){ // check if form want (delete check apply forms) e.preventdefault(); jquery.ajax({ type: "post", url: create_acct_form .attr("action"), data: create_acct_form .serialize(), // serializes form's elements. success: function(data) { console.log(data); if( data.status == 'error' ) { // error handling, show data.message or want. } else { // same above success $("#createacctform")[0].reset(); $("#create_acct-info").html(data) } } }); } });
you can add ajaxstart
, ajaxend
handlers , can show loading image this:
$(document) .ajaxstart(function() { $(some image).show(); }) .ajaxstop(function() { $(some image).hide(); });
Comments
Post a Comment