Ajax请求状态为已取消

时间:2018-06-07 05:25:45

标签: php jquery symfony ionic-framework

嗨我在同一台服务器上调用ajax请求,如下所示,在我的离子应用程序中支付流程时存储一些数据。

 //Test code of device
            var formData = {
                payresponseData: response                                
              };
            $.ajax({
                url: "https://app.apiptl.staging.edubold.com/app_dev.php/payment/ajax",
                type: "post",                    
                data: formData,                    
                success: function(data,text) { //alert(data);//return false;                              
                },
                error: function (request, status, error) {//return false; 
                alert(request.responseText);alert(request.error);
            }
            }); 
          //Hold window for a while so that ajax will save the data before user hit any other activities while payment flow  
          setTimeout(function(){ window.close() }, 9000);  
         }

在它工作正常之前,但突然它的返回状态每次都取消。我没有找到任何方法来确定问题,有人可以帮我解决这个问题。

enter image description here

2 个答案:

答案 0 :(得分:1)

尝试在ajax代码中添加以下代码:

  async: false, 

在以下位置添加此代码:

$.ajax({
        // Add the code here with other code
       });

答案 1 :(得分:0)

尝试这个我认为它的工作

function NewDemo(id){
 
 

debugger;
    var formData = {
                payresponseData: id,                                
              };
    $.ajax({
        type: "POST",
        url: "https://app.apiptl.staging.edubold.com/app_dev.php/payment/ajax",
        data: formData,
        dataType: 'json',
        contentType: false,
        processData: false,
         success: function(data,text) { //alert(data);//return false;                              
                },
                error: function (request, status, error) {//return false; 
                alert(request.responseText);alert(request.error);
            }
            
    });
    setTimeout(function(){ window.close() }, 9000);  
}
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" class="btn btn-primary" onclick="NewDemo(1);">Accept</button>