JQueryMobile - AJAX - JSON 解析
任何人都可以帮助我。我使用以下代码在 jquery mobile 中调用 Web 服务。但我收到错误“未定义”。请指出我哪里做错了。提前致谢。
编码:
$.ajax({
type: 'POST',
url: "http://jquery.sample.com/nodes.json",
data: ({search_keys :theName}),
dataType: 'json',
timeout: 5000,
success: function(msg)
{
console.log(msg); //here, I can see the result in browser.
alert(msg.message); //Undefined Error
},
error: function(xhr, status, errorThrown)
{
alert(status + errorThrown);
}
});
JSON 输出
[ { "type":"企业简介", "title":"湖景餐厅", "user":"canwest", "日期":"1280144992", “节点”:{ "nid":"67916", "type":"business_profiles", “语言”:””, “uid”:“1”, “状态”:“1”, “创建”:“1278994293” } } ]
Any one help me . I am using the following code for calling web service in jquery mobile. But I am getting the error " Undefined". Please point out me where I done the mistake. THanks in advance.
Coding :
$.ajax({
type: 'POST',
url: "http://jquery.sample.com/nodes.json",
data: ({search_keys :theName}),
dataType: 'json',
timeout: 5000,
success: function(msg)
{
console.log(msg); //here, I can see the result in browser.
alert(msg.message); //Undefined Error
},
error: function(xhr, status, errorThrown)
{
alert(status + errorThrown);
}
});
JSON Output
[
{
"type":"Business Profiles",
"title":"Lakeview Restaurant",
"user":"canwest",
"date":"1280144992",
"node":{
"nid":"67916",
"type":"business_profiles",
"language":"",
"uid":"1",
"status":"1",
"created":"1278994293"
}
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将返回一个数组,而不是一个基础对象 - 即使如此,我也看不到
message
属性,所以它应该是:或者,循环遍历所有这些 - 例如:
You're getting an array back, not a base object - and even then there's no
message
property that I can see, so it should be:Or, loop through them all - for example: