我试图获取值“shortmessage”并将其显示在我的HTML正文中。在我下面我一直在搞乱。谢谢你的帮助!
$.ajax({
url: 'http://www.myURL.com',
type: 'GET',
crossDomain: true,
dataType: 'jsonp',
success: function(data){
//What I am trying
$("body").append(JSON.stringify(010017.shortmessage));
}
});
{"010017":{"shortmessage":"Jeans On Sale!","enddate":"10\/15\/2013 23:59:59","longmessage":"Save on your favorite Levi Jeans!","style":"010017"}}
答案 0 :(得分:0)
您需要在成功函数中使用data属性。
$('body').append(data['010017'].shortmessage);
如果您正在使用ASP.Net 3.5+进行请求,则可能需要添加.d
数据变量:
$('body').append(data.d['010017'].shortmessage);
答案 1 :(得分:0)
var jUrl = {"010017":{"shortmessage":"Jeans On Sale!","enddate":"10\/15\/2013 23:59:59","longmessage":"Save on your favorite Levi Jeans!","style":"010017"}};
alert(jUrl["010017"].shortmessage);