任何人帮助我。我正在使用以下代码在 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":"Business Profiles", "title":"Lakeview Restaurant", "user":"canwest", "date":"1280144992", "node":{ "nid":"67916" , "type":"business_profiles", "language":"", "uid":"1", "status":"1", "created":"1278994293" } } ]