我红色的堆栈溢出一些文章和类似的问题,但没有真的找到任何简单的干净的解决方案来解决这个问题。实现jquery ajax调用加载gif图像
例如这是我的AJAX功能:
$.ajax({
url: "/Home/AddSong",
type: "POST",
data: $("#AddTopTenFavForm").serialize(),
success: function (data) { ShowMsg("Song Added Successfully"), $(container).find('ul').append('
' + name + ' x'); },error: function() { ShowMsg("There was an error therefore song could not be added, please try again") }
});
我想打电话给我的功能:
function ShowAjaxLoader() {
$("#dottedWrapper").fadeIn();
$("#loadingGifContainer").fadeIn();
}
function HideAjaxLoader() {
$("#dottedWrapper").fadeOut(1000);
$("#loadingGifContainer").fadeOut(1000);
}
当Ajax请求开始,当它完成。请帮助感谢
+0
看看http://docs.jquery.com/Ajax_Events这是你需要的。只需将您的函数添加到ajax调用中的relivant事件中即可。 –