作者:saanenkim | 来源:互联网 | 2023-10-12 14:53
像这样:
var cancelMe = setTimeout(function() {
$('#loading').show(); // assuming your loading element has the id "loading"
}, 2000); // show loading element in 2 seconds
jQuery.ajax({
url: "loadData.php",
dataType: 'json',
type: 'GET',
success: function(result){
showResultsToUser(result);
clearTimeout(cancelMe); // don't run if it hasn't run yet
$('#loading').hide(); // hide the loading element if it's shown
}
});