我正在编写一些代码来自学 ExtJS 的方法。我对 JSON 也很陌生,所以希望这个问题对你来说很容易回答。我正在尝试从我编写的基本网络服务中检索一些数据should将其结果作为 JSON 返回(因为我是 JSON 新手 - 可能是它被破坏了)。
我得到的错误是
语法错误:缺少 ) 中
括号内的
我从 Web 服务返回的 JSON 是
{
"rows": [
{
"id": "100000",
"genre_name": "Action",
"sort_order": "100000"
}, {
"id": "100002",
"genre_name": "Comedy",
"sort_order": "100002"
}, {
"id": "100001",
"genre_name": "Drama",
"sort_order": "100001"
}]
}
我的 ExtJS 代码如下。这loadexception
回调是我从中检索 JSON 和上面错误的地方
var genres = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: 'http://localhost/extjs_training/Demo_WebService/Utility.asmx/GetGenres',
failure: function(response, options){
Ext.get('my_id').dom.innerHTML = 'Load failed: ' + response.status;
}
}),
reader: new Ext.data.JsonReader({
fields: ['id', 'genre_name'],
root: 'rows'
}),
listeners: {
loadexception: function (proxy, options, response, e) {
var result = response.responseText;
Ext.MessageBox.alert('Load failure', e + " ..... " + result);
}
}
});
var loadSuccess = genres.load({
callback: function(r, options, success){
Ext.get('my_id').dom.innerHTML = 'Load status: success=' + success;
}
});