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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图