Am using Ajax to send a request to a web server, but will like to show user with a GIF image indicating them to wait till the request is completed.
Can you please help me modify this code to load GIF image on sending the request.
jQuery(document).submit(function(e){
var create_acct_form = jQuery(e.target);
if(create_acct_form .is("#createacctform")){ // check if this is the form that you want (delete this check to apply this to all forms)
e.preventDefault();
jQuery.ajax({
type: "POST",
url: create_acct_form .attr("action"),
data: create_acct_form .serialize(), // serializes the form's elements.
success: function(data) {
console.log(data);
if( data.status == 'error' ) {
// error handling, show data.message or what you want.
} else {
// same as above but with success
$("#createacctform")[0].reset();
$("#create_acct-info").html(data)
}
}
});
}
});