在这个演示站点,我使用ajax和Tumblr对文章进行排序。所有操作都很完美,有着高效的错误处理,但是由于我对jQuery非常陌生,我想知道在加载内容时,我应该如何/在哪里/做些什么来显示一个旋转器?
下面是我用来加载帖子的代码:
function byCategory(postType, callback) {
jQuery.ajax({
type: "GET",
url: '{URL}/api/read/json?type=' + postType +
'&callback=?',
dataType: "json",
success: function(results){
console.info("Success!");
yourCallbackToRunIfSuccessful(results);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
console.info("Error, the Tumblr API is down and cannot serve your request");
yourErrorHandler(XMLHttpRequest, textStatus, errorThrown);
}
});来自忍者的任何帮助,我们将不胜感激:)
发布于 2011-02-24 23:12:09
在触发函数时单击或提交按钮上的$('#spinner').show() (只需将其放在函数开始后,在ajax调用之上)
在成功的过程中,只需做一个$('#spinner').hide();
https://stackoverflow.com/questions/5111704
复制相似问题