读取JSON数据返回的jQuery [英] Reading json data return to jQuery
本文介绍了读取JSON数据返回的jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code得到一些JSON格式的数据:
I'm using the following code to get some json formatted data:
$.ajax({
type: "GET",
url: "MyService.svc/GetSomeData",
dataType: "text",
success: function (data, textStatus) {
alert("Test: " + data.toString());
},
error: function (xhr, textStatus, errorThrown) {
alert("Error: " + (errorThrown ? errorThrown : xhr.status));
}
});
数据成功地返回到该电话,它看起来是这样的:
Data is successfully returned to this call, and it looks like this:
{"d":"test data"}
我的猜测是,我可以按如下方法访问数据:
My guess was that I could access the data as follows:
var myData = data["d"];
不过,这似乎总是返回未定义。我在想什么来获取数据的单一字符串测试数据?
However this seems to always return "undefined". What am I missing to get the single string of data "test data"?
推荐答案
如果您尝试会发生什么 data.d
?
what happens if you try data.d
?
这篇关于读取JSON数据返回的jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文