0
http://localhost:2000/WebService/Handler.ashx?d=ck

查看 URL 时的响应:

{"Status":"OK","Message":"0","Info":"(none)"}

使用 JQuery 我如何从中提取?我知道你是如何进行 POST 和发送的,但对于如何从中提取信息来说几乎没有什么损失。我使用 GET 吗?

我在做类似 $.get("URL HERE"...?

4

3 回答 3

2
$.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;
    ...
});
于 2012-06-15T15:34:49.063 回答
1

您可以使用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); 
  }
});
于 2012-06-15T15:34:23.697 回答
0

使用jquery 的jQuery.ajaxjQuery.getJSON函数。

 $.ajax({
  url: url,
  dataType: 'json',
  data: data,
  success: callback
});

或者这样...

 $.getJSON('ajax/test.json', {data: data },function(data) {
      // do as needed
 });
于 2012-06-15T15:44:49.090 回答