$.ajax({
url: "/cgi-bin/stats.exe",
method: "post",
async: false,
data: { refresh: "a41" }
});
同步使用ajax post - “async: false”。
虽然它会在事件请求期间阻止浏览器,但将光标更改为沙漏或显示等待 .gif 的最有效方法是什么?
也许在进入此功能时设置光标,然后将其更改回 success or complete function ?
如有任何建议,我们将不胜感激。
谢谢。
最佳答案
我还没有测试过这个,但我认为应该像这样完成:
$('html, body').css('cursor', 'wait');
$.ajax({
url: "/cgi-bin/stats.exe",
method: "post",
async: false,
data: { refresh: "a41" },
success: function() {
$('html, body').css('cursor', 'auto');
// the rest of your processing here
},
error: function() {
$('html, body').css('cursor', 'auto');
}
});
根据@patrick的建议,错误时也将其改回。
关于javascript - 如何在 jQuery 同步浏览器阻止 POST 期间更改光标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2685748/