在运行AJAX时更改光标

时间:2019-03-04 16:04:06

标签: jquery css ajax

我有一个字段和一个按钮,它们使用AJAX执行搜索。我希望在运行搜索时将光标更改为“ progress”,然后在完成搜索后将其恢复为“ default”。

psycopg2.DataError: invalid input syntax for type double precision:
"NULL" CONTEXT:  COPY test_table, line 25, column Lat:
"NULL"

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

谢谢!

1 个答案:

答案 0 :(得分:0)

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

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";
        }
    });
}