I would like to display loading indicator while data is loading. below is my current codes:
$.ajax({
type: "POST",
url: "URL",
data: dataString,
cache: false,
success: function(html) {
$("#div").html(html);
}
});
What should I do?
use this:
$.ajax({
type: "POST",
url: "URL",
data: dataString,
cache: false,
success: function(html) {
$(selector).html();
$("#div").html(html);
},
beforeSend: function(){
$(selector).html("your loading image");
}
});
$(selector).html();
You may use jquery ajaxStart and ajaxStop utilities for this.
like
$( document ).ajaxStart(function() {
$( "#loading" ).show();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With