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



当初始 ajax post 完成时,我正在尝试进行第二次 ajax 调用,初始调用是 Post,第二次调用是 get 类型,在第二次调用中,我能够获取 url 文件的值.php但不能将返回的值用作条件条件参数。

这是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
});

响应还包含到末尾的新行。在这种情况下,最好检查字符串是否包含。

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