我有一個Web服務,它返回JSON數據,下面我用來調用Web服務的代碼。如何通過AJAX調用Web服務來返回Json數據?
jQuery.ajax({
url: 'http://localhost:5606/xyz',
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: '{"a":"b"}',
success: function(responses, textStatus, XMLHttpRequest) {
alert(responses);
},
error: function(xhr, err) {
console.log("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
console.log("responseText: " + xhr.responseText);
},
complete: function() {}
});
};
其返回警報輸出成功的功能像[目標對象]但我想它在正確的JSON格式。
使用'的console.log()''不alert' – guradio
但我想響應值調用另一個webservice –
這就是要點。您可以獲取JSON數據,不要「提醒」它,只需將其記錄在控制檯中即可。 –