Jquery Ajax 加载图片 [英] Jquery Ajax Loading image
本文介绍了Jquery Ajax 加载图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为我的 jquery ajax 代码实现一个加载图像(这是 jquery 仍在处理的时候)下面是我的代码:
$.ajax({类型:获取",网址:网址,数据类型:jsonp",缓存:假,jsonp : "onJSONPLoad",jsonpCallback: "newarticlescallback",跨域:真",成功:功能(响应){警报(成功");},错误:函数(xhr,状态){alert('未知错误' + 状态);}});
如何在此代码中实现加载图像.谢谢
解决方案
试试这个:
<脚本>函数ajaxCall(){$("#LoadingImage").show();$.ajax({类型:获取",网址:网址,数据类型:jsonp",缓存:假,jsonp : "onJSONPLoad",jsonpCallback: "newarticlescallback",跨域:真",成功:功能(响应){$("#LoadingImage").hide();警报(成功");},错误:函数(xhr,状态){$("#LoadingImage").hide();alert('未知错误' + 状态);}});}
I would like to implement a loading image for my jquery ajax code (this is when the jquery is still processing) below is my code:
$.ajax({
type: "GET",
url: surl,
dataType: "jsonp",
cache : false,
jsonp : "onJSONPLoad",
jsonpCallback: "newarticlescallback",
crossDomain: "true",
success: function(response) {
alert("Success");
},
error: function (xhr, status) {
alert('Unknown error ' + status);
}
});
How can I implement a loading image in this code. Thanks
解决方案
Try something like this:
<div id="LoadingImage" style="display: none">
<img src="" />
</div>
<script>
function ajaxCall(){
$("#LoadingImage").show();
$.ajax({
type: "GET",
url: surl,
dataType: "jsonp",
cache : false,
jsonp : "onJSONPLoad",
jsonpCallback: "newarticlescallback",
crossDomain: "true",
success: function(response) {
$("#LoadingImage").hide();
alert("Success");
},
error: function (xhr, status) {
$("#LoadingImage").hide();
alert('Unknown error ' + status);
}
});
}
</script>
这篇关于Jquery Ajax 加载图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文