[英]AJAX response 0 while sending API request using SOAP - php
jQuery的:
jQuery.ajax
({
url: ajaxurl,
type: 'POST',
data: {
action: 'shipping_data',
},
processData: false,
success: function(data)
{
alert(data);
},
error: function(data)
{
alert("failed.");
}
});
PHP:
function shipping_data()
{
// Testing for now.
$requestParams = array(
'CityName' => 'Berlin',
'CountryName' => 'Germany'
);
$client = new SoapClient('http://www.webservicex.net/globalweather.asmx?WSDL');
echo $response = $client->GetWeather($requestParams);
die();
}
add_action( 'wp_ajax_shipping_data', 'shipping_data' );
add_action( 'wp_ajax_nopriv_shipping_data', 'shipping_data' );
我使用processData: false,
並獲得響應0。在我獲得失敗響應之前。 為什么我無法收到請求? 如果我在shipping_data
函數之外使用SOAP,那么我可以獲得響應。 但是我想在shipping_data
函數(使用ajax調用)中使用任何幫助嗎?
0是ajax的默認錯誤代碼,無論您做什么都是硬編碼錯誤。 大多數時候使用die(); 它將破壞一切,請嘗試將其替換為
exit;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.