我有一个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数据,不要“提醒”它,只需将其记录在控制台中即可。 –