donglei3370 2015-10-22 19:37
浏览 25

AJAX有时不会执行成功或错误

I have an application form that is being handled by jQuery and different AJAX calls. Basically there are five different functions that are being called and if they succeed the next one is being called and so on until the user gets a final answer to their application.

And during this process the user gets feedback about what's happening from a simple dialog window with text that gets updated along the way.

The first two AJAX calls and this third one works without a problem for myself and several others. But some users cant get past the third one. So they get stuck at this point and don't get any output and answer to their application.

The PHP works fine and does its job and returns a correct json-string.

$.ajax({
    type: "POST",
    url: "/applications/includes/process_formsave.php",
    cache: false,
    success: function(data) {

        var result = jQuery.parseJSON(data);

        if(result['status'] == "error") {
            processError("31");
        } else if(result['status'] == "denied") {
            $(".handling-text").text("Handling application");
            processOutput();
        } else {
            $(".handling-text").text("Performing credit report");
            processCS();
        }

    },
    error: function(data) {
        processError("#32");
    },
    complete: function(data) {

        var result = jQuery.parseJSON(data);

        if(result['status'] == "error") {
            processError("#33");
        } else if(result['status'] == "denied") {
            $(".handling-text").text("Handling application");
            processOutput();
        } else if(result['status'] == "success") {
            $(".handling-text").text("Performing credit report");
            processCS();
        } else {
            processError("#34");
        }

    }
});

At first I didn't have the "complete" part included but read somewhere that if "success" and "error" didn't fire "complete" always will. But it didn't change anything. But I left it in there for safety.

I can also add that a lot of the users use mobile. It works fine on iOS so it might be Android related. But I'm just guessing at this point.

So any ideas what the problem might be?

Edit: After some more testing and inserting some log points i found that the success is in fact called. But the data that is returned is blank. The weird thing is that if I save the json-string to the database before echoing it in the php it looks like it should.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题