我使用下面的PHP代理的響應:PHP代理AJAX不返回POST
//Store the URL
$jURL = $_POST['jURL'];
//Store the POST data
$jData = $_POST['post_data'];
//And let cURL work it's magic.
$ch = curl_init();
//Set the URL
curl_setopt($ch, CURLOPT_URL, $jURL);
//Enable POST data
curl_setopt($ch, CURLOPT_POST, true);
//Use the $pData array as the POST data
curl_setopt($ch, CURLOPT_POSTFIELDS, $jData);
//curl_exec automatically writes the data returned
$response = curl_exec($ch);
curl_close($ch);
echo $response;
,我通過調用它:
var dataString = { 'Contact': Contact, 'address1': address1, 'address2': address2, 'city': city, 'state': state, 'zip': zip, 'Phone1': primPhone, 'Phone2': secPhone, 'email': email,
'key2': key2, 'key5': key5, 'uhsgradyr': uhsgradyr, 'uhighlevel': uhighlevel, 'ucourseint': ucourseint, 'uCampaignID': uCampaignID, 'utextperm':utextperm,
'uleaddate': uleaddate, 'uleadtime':uleadtime};
var postData = {jURL: 'http://test.com/candidate_test.php', postData: dataString};
$.ajax({
type: "POST",
url: "proxy.php",
data: postData,
success: function(data) {
window.location = "thankyou.php";
},
error:function(xhr, ajaxOptions, thrownError){
console.log(xhr.responseText);
}
});
的問題是,爲什麼我還沒有得到任何迴應?
謝謝,你有什麼不對嗎?我有點困惑,我有什麼dataString我有 – aherlambang
,仍然沒有迴應 – aherlambang
@aherlambang:你確定「PHP代理」的作品嗎?即從'$ _POST'替換所有東西你自己的變量,並自己調用PHP文件。另外,請確保你通過Chrome的網絡檢查器或Firefox Firebug中的Network選項卡檢查ajax調用。 – chelmertz