【发布时间】:2013-03-20 09:43:13
【问题描述】:
如何在 Sencha Touch 中捕获使用 PHP 生成的 JSON 数据?有人知道这方面的好教程吗?
我正在尝试使用以下代码获取 JSON 数据
Ext.util.JSONP.request({
url: 'proc/getEvents.php',
callbackKey: 'callback',
callback: function(data) {
var lists = data.results;
timeline.update(lists); // Update events lists
}
});
我的 JSON 数据是这样的(由 getEvents.php 生成):
{
"sample":[
{
"id":"1",
"name":"131\/E Address",
"desc":"This is where I live!!",
"lat":"0",
"lon":"0",
"starttime":"0",
"endtime":"0",
"flag":"0"
},
{
"id":"2",
"name":"INOX",
"desc":"Central Mall",
"lat":"0",
"lon":"0",
"starttime":"0",
"endtime":"0",
"flag":"0"
}
]
}
现在我想在模板中显示它。
tpl: [
'<tpl for=".">',
'<div class="details">',
'<h2>{name}</h2>',
'<p>{desc}</p>',
'</div>',
'</tpl>'
]
谁能帮我找出问题所在?我的 javascript 控制台说(使用 getEvents.php)
Resource interpreted as Script but transferred with MIME type text/html.
getEvents.php:1Uncaught SyntaxError: Unexpected token :
【问题讨论】:
标签: json sencha-touch