doupa2871 2015-04-11 04:10 采纳率: 100%
浏览 64

在初始Ajax POST调用之后传递Ajax GET响应

I am trying to do a second ajax call when initial ajax post is done, the initial call is a Post and the second call is a get type, on the second call I am able to get the values of url file.php but can't use the returned value as a condition condition parameter.

here's a copy of the js:

$.ajax({
    type: 'POST',
    url: $(form).attr('action'),
    data: formData,
    async: false,
    cache: false,
    contentType: false,
    processData: false,
    dataType: 'json'
})
.done(function() {
    //SOME UI UPDATES ARE HAPPENNG HERE
    //SOME OTHER AJAX CALL AFTER INITIAL CALL IS DONE
    $.ajax({
        url: 'progress.php',
        type: 'GET',
        data: status,
        async:false,
        cache:false
    })
    .done(function(response) {
        console.log("success"); // GETS STRING VALUE OF PROGRESS.PHP
        if (response == "success") {
            //DO SOMETHING ELSE
        };
    })
    .fail(function(response) {
        console.log("error");
    });

})
.fail(function() {
    //console.log("error");
    //INITIAL POST ERROR GOES HERE
});
  • 写回答

1条回答 默认 最新

  • dtbl1231 2015-04-11 05:55
    关注

    response also contains a new line to the end. Better checking the string contains in this case.

    response.indexOf('success') !== -1
    
    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决