http://localhost:2000/WebService/Handler.ashx?d=ck
响应拉查看URL时:使用jQuery从Ajax响应
{"Status":"OK","Message":"0","Info":"(none)"}
使用jQuery我如何从拉?我得到你如何做POST和发送但很少失去了如何从中拉。我使用GET吗?
我做类似$获得( “URL HERE” ......
http://localhost:2000/WebService/Handler.ashx?d=ck
响应拉查看URL时:使用jQuery从Ajax响应
{"Status":"OK","Message":"0","Info":"(none)"}
使用jQuery我如何从拉?我得到你如何做POST和发送但很少失去了如何从中拉。我使用GET吗?
我做类似$获得( “URL HERE” ......
$.ajax({
url:"...",
dateType: "json", // <=== you expect "JSON" string
success: function(data){
alert(data.Status); // Extract the data from the response.
alert(data.Message);
alert(data.Info);
}
});
或者速记getJSON
功能:
$.getJSON(url,function(data){
data.Status;
...
});
可以使用ajax函数中检索你的JSON响应:
$.ajax({
url: 'http://localhost:2000/WebService/Handler.ashx?d=ck',
dataType: 'json',
success: function(data) {
console.log(data);
console.log('Status: ' + data.Status);
}
});
使用jQuery.ajax或jQuery.getJSON jquery的功能。
$.ajax({
url: url,
dataType: 'json',
data: data,
success: callback
});
还是这样...
$.getJSON('ajax/test.json', {data: data },function(data) {
// do as needed
});
http://api.jquery.com/jQuery.getJSON/ – Blazemonger
除非你的web服务返回CORS标题或适当JSONP,它不会,如果工作localhost:2000与请求数据的页面不是同一个域和端口。 –