jquery - How can i display the data after few seconds? -
i know shouldn't want make spinner longer user. because moment ajax request quick user not able see spinner.
is there anyway put @ least 5 secondes instance, after these 5 second data displayed.
$.ajax({ type: "post", url: $('#ajaxmorestatus').attr("data-url"), datatype: "html", beforesend: function() { $('.spinner').show(); }, complete: function() { $('.spinner').hide(); }, success: function (data) { $('#ajaxmorestatus').append(data); } });
just use settimeout fake delays:
$.ajax({ type: "post", url: $('#ajaxmorestatus').attr("data-url"), datatype: "html", beforesend: function() { $('.spinner').show(); }, complete: function() { settimeout(function () { $('.spinner').hide(); }, 5000); // 5 seconds. }, success: function (data) { $('#ajaxmorestatus').append(data); } }); if want delay loading too, use on success function too:
$.ajax({ type: "post", url: $('#ajaxmorestatus').attr("data-url"), datatype: "html", beforesend: function() { $('.spinner').show(); }, complete: function() { settimeout(function () { $('.spinner').hide(); }, 5000); // 5 seconds. }, success: function (data) { settimeout(function () { $('#ajaxmorestatus').append(data); }, 5000); // 5 seconds. } });
Comments
Post a Comment