http://localhost:2000/WebService/Handler.ashx?d=ck
查看 URL 时的响应:
{"Status":"OK","Message":"0","Info":"(none)"}
使用 JQuery 我如何从中提取?我知道你是如何进行 POST 和发送的,但对于如何从中提取信息来说几乎没有什么损失。我使用 GET 吗?
我在做类似 $.get("URL HERE"...?
http://localhost:2000/WebService/Handler.ashx?d=ck
查看 URL 时的响应:
{"Status":"OK","Message":"0","Info":"(none)"}
使用 JQuery 我如何从中提取?我知道你是如何进行 POST 和发送的,但对于如何从中提取信息来说几乎没有什么损失。我使用 GET 吗?
我在做类似 $.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 的jQuery.ajax或jQuery.getJSON函数。
$.ajax({
url: url,
dataType: 'json',
data: data,
success: callback
});
或者这样...
$.getJSON('ajax/test.json', {data: data },function(data) {
// do as needed
});