2016-08-31 153 views
-1

我有以下jQuery代碼將數據發佈到php文件,並在本地主機上正常工作。但是,當此代碼現在在服務器上時,腳本將返回錯誤而不是數據。Jquery Ajax沒有在服務器上工作,但在本地主機上工作

$.ajax({ 
     type: 'POST', 
     url: 'scripts/info.php', 
     data: { 

      accountNumber: accountNumber, 
      agentName: name 

     }, 
     success: function(data) { 
      alert(data) 
     }, 
     error: function(xhr, status, error) { 
      // check status && error 
      alert(status) 
     } 
    }); 

這是在處理POST請求的PHP文件中的代碼:

$args0 = array(
'accountNumber' => $_POST['accountNumber'], 
'dateReceived' => date("Y-m-d"), 
'firstNames' => $_POST['agentName'] ' 
'regNumber' => $_POST['accountNumber'], 
'surname' => $_POST['agentName'] 
); 

try { 
$client = new SoapClient(WSDL_URL, array(
    'trace' => 1, 
    'exceptions' => true, 
    'connection_timeout' => 300)); 

$params = array(
    'arg0' => $args0, 

); 


$client->__setLocation(WSDL_LOCATION); 
$response = $client->upload($params); 
$response = $client->__getLastResponse(); 

echo $response; 

請幫

+0

什麼是控制檯錯誤? – Perspective

+0

沒有控制檯錯誤 – Deant

+0

我一直在尋找解決方案,但我找不到任何解決方案 – Deant

回答

0
$.ajax({ 
    type:"post", 
    url:"/pay/index.php?submit_order=yes", 
    dataType:'json', 
    data:{ 
     'rmb': $('#rmb').val(), 
     'couponid': $('#cid').val(), 
     'title' :$('#title').text(), 
     'user' :$('#user').text(), 
     'phone' :$('#phone').text(), 
     'code' :$('#code').text(), 
     'size' :$('#size').text(), 
     'isinvoice':$('[name=isinvoice]').val() 
    }, 
    beforeSend:function(){ 
     beforeSend.attr('disabled',true); 
     beforeSend.html('submitting').removeAttr('href'); 
    }, 
    success:function(data){ 
     if(data.errorcode==1){ 
      $('.pay-fail').show().text(data.message); 
     }else{ 
      if(data.url){ 
       location.href=data.url; 
      }else{ 
       alert('post ok!'); 
      } 
     }      
    }, 
    error: function(){ 
     alert('submit error,then try again'); 
    } 
}) 

這是我的jQuery AJAX的薪酬。它適用於本地主機和服務器上。

相關問題