gpt4 book ai didi

jquery - AJAX 运行时更改光标

转载 作者:行者123 更新时间:2023-11-28 00:18:15 25 4
gpt4 key购买 nike

我有一个字段和一个使用 AJAX 执行搜索的按钮。我希望在搜索运行时光标变为“progress”,然后在搜索完成时返回“default”。

function getFromFile(pFilePath, pFileName, pParseType) {
var vCompletePath = pFilePath + pFileName;

$.ajax({
beforeSend: function(){$("body").css("cursor","progress");},
type: "GET",
url: vCompletePath,
dataType: pParseType,
async: false,
success: function(data) {
console.log("Data retrieval was successful!");
aReturnedContent = data;
},
error: function() {
console.log("Data retrieval was unsuccessful!");
},
complete: function(){$("body").css("cursor","default");}
});
}

我尝试了一些方法(包括 beforeSend 和 complete 设置),但没有任何效果。有什么想法吗?

谢谢!

最佳答案

你可以像这样设置你的光标(与页面中的加载器相同):

function getFromFile(pFilePath, pFileName, pParseType) {
var vCompletePath = pFilePath + pFileName;

$("body").style.cursor = "progress";
$.ajax({
type: "GET",
url: vCompletePath,
dataType: pParseType,
async: false,
success: function(data) {
console.log("Data retrieval was successful!");
aReturnedContent = data;
$("body").style.cursor = "default";
},
error: function() {
console.log("Data retrieval was unsuccessful!");
$("body").style.cursor = "default";
}
});
}

如果在 jQuery 中不起作用:

function getFromFile(pFilePath, pFileName, pParseType) {
var vCompletePath = pFilePath + pFileName;

document.body.style.cursor = "progress";
$.ajax({
type: "GET",
url: vCompletePath,
dataType: pParseType,
async: false,
success: function(data) {
console.log("Data retrieval was successful!");
aReturnedContent = data;
document.body.style.cursor = "default";
},
error: function() {
console.log("Data retrieval was unsuccessful!");
document.body.style.cursor = "default";
}
});
}

关于jquery - AJAX 运行时更改光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54987040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com