我的 jQuery.ajax 返回 JSon 对象。我首先阅读了其他文章。但他们的回复文字不喜欢我的。我的回复内容:来自萤火虫响应
{"item":"[{\"country\":\"USA\",\"lan\":\"EN\"},{\"country\":\"Turkiye\",\"lan\":\"TR\"}]"}
现在我试图提醒countryName:
$('#loadData').click(function() {
$.ajax({
type: "POST",
url: "WS/myWS.asmx/getDaa",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#jsonResponse").html(msg);
$.each(msg.item, function(i, d) {
alert(this.country);
debugger;
});
},
});
});
但它令人警觉“不明确的”
item 的值是一个字符串。因此,您首先需要将其解析为 json。尝试这个。
$("#jsonResponse").html(msg);
var item = jQuery.parseJSON(msg.item)
$.each(item, function(i, d) {
alert(this.country);
debugger;
});
},
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)