这段代码
$("#loading").ajaxStart(function() {
alert("start");
$(this).show();
});
Run Code Online (Sandbox Code Playgroud)
在我的加价
<div style="text-align:center;"><img id="loading" src="../images/common/loading.gif" alt="" /></div>
Run Code Online (Sandbox Code Playgroud)
这是完整的ajax请求:
$.ajax({
type: "POST",
url: "http://localhost/WebServices/Service.asmx/GetResults",
data: jsonText,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
var results = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
PopulateTree(results);
},
error: function(xhr, status, error) {
var msg = JSON.parse(xhr.responseText);
alert(msg.Message);
}
});
$("#loading").ajaxStart(function() {
alert("start");
$(this).show();
});
$("#loading").ajaxStop(function() {
alert("stop");
$(this).hide();
$("#st-tree-container").show();
});
Run Code Online (Sandbox Code Playgroud)
即使gif显示为旋转,也不会触发警报"开始".AjaxStop按预期触发.有什么想法吗?
我有以下jQuery Ajax调用:
$.ajax({
type: "POST",
url: "addtobasket.php",
data: "sid=<?= $sid ?>&itemid=" + itemid + "&boxsize=" + boxsize + "&ext=" + extraval,
success: function(msg){
$.post("preorderbasket.php", { sid: "<?= $sid ?>", type: "pre" },
function(data){
$('.preorder').empty();
$('.preorder').append(data);
});
}
});
Run Code Online (Sandbox Code Playgroud)
我想在ajax调用进行时显示图像.我怎样才能做到这一点?
谢谢,