0
Ext.define('Olvldefnition', {
    extend: 'Ext.data.Model',
    fields: [
        {
                        name : 'defKey'
        },
        {
            name : 'defStructKey',
            type : 'int'
        },
        {
            name : 'defLevelNo',
            type : 'int'
        }, {
            name : 'defLevelDiscP',
            type : 'string'
        }, {
            name : 'defLevelDiscS',
            type : 'string'
        }, {
            name : 'defSeqNo',
            type : 'int'
        }
    ]
});


var storeDef = Ext.create('Ext.data.Store', {
    id: 'storeDef',
    model: 'Olvldefnition',
    proxy: {
       type: 'jsonp',
       api : {
    read : 'definition/view.action'
},
        reader: {
            type: 'json',
             root: 'data',
             idProperty: 'defKey',
             successProperty : 'success',
             messageProperty : 'message'
        }
 }
}); 

これは、次のような JSON データを取得する私のコードです。

{
"total":3,
"data":[
{"modifiers":{"status":"A","effstartdate":"2012-04-02 00:00:00.0","effenddate":"2012-04-26 00:00:00.0","updateUser":"ARCSADMIN","updateDate":"2012-04-16 16:04:29.162","remarks":null,"entryDate":"2012-04-07 19:34:28.923","entryUser":"ARCSADMIN"},
"defKey":105,
"defSeqNo":2,
"defStructKey":73,
"defLevelNo":1,
"defLevelDiscP":"Branch",
"defLevelDiscS":"Branch",
"olvstructure":{"modifiers":{"status":"A","effstartdate":"2012-04-06 00:00:00.0","effenddate":"2012-04-27 00:00:00.0","updateUser":"ARCSADMIN","updateDate":"2012-04-06 20:03:43.817","remarks":"Remark","entryDate":"2012-04-06 20:03:37.252","entryUser":"ARCSADMIN"},"olsKey":73,"olsSeqNo":1,"olsLevel":3,"olsSeperator":"-"}},{"modifiers":{"status":"A","effstartdate":"2012-04-02 00:00:00.0","effenddate":"2012-05-23 00:00:00.0","updateUser":"ARCSADMIN","updateDate":"2012-04-30 12:22:12.899","remarks":null,"entryDate":"2012-04-07 19:33:58.405","entryUser":"ARCSADMIN"},"defKey":104,"defSeqNo":1,"defStructKey":73,"defLevelNo":2,"defLevelDiscP":"Dept1","defLevelDiscS":"Dept1","olvstructure":{"modifiers":{"status":"A","effstartdate":"2012-04-06 00:00:00.0","effenddate":"2012-04-27 00:00:00.0","updateUser":"ARCSADMIN","updateDate":"2012-04-06 20:03:43.817","remarks":"Remark","entryDate":"2012-04-06 20:03:37.252","entryUser":"ARCSADMIN"},"olsKey":73,"olsSeqNo":1,"olsLevel":3,"olsSeperator":"-"}},{"modifiers":{"status":"I","effstartdate":null,"effenddate":null,"updateUser":null,"updateDate":null,"remarks":null,"entryDate":"2012-04-19 13:52:04.676","entryUser":"ARCSADMIN"},"defKey":118,"defSeqNo":3,"defStructKey":73,"defLevelNo":3,"defLevelDiscP":"sdasda","defLevelDiscS":"dsd","olvstructure":{"modifiers":{"status":"A","effstartdate":"2012-04-06 00:00:00.0","effenddate":"2012-04-27 00:00:00.0","updateUser":"ARCSADMIN","updateDate":"2012-04-06 20:03:43.817","remarks":"Remark","entryDate":"2012-04-06 20:03:37.252","entryUser":"ARCSADMIN"},"olsKey":73,"olsSeqNo":1,"olsLevel":3,"olsSeperator":"-"}}],"message":"view","success":true}

しかし、それはこのようなエラーを示しています

SCRIPT1004: Expected ';' 
view.action?_dc=1337079455042&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1, line 1 character 9
4

2 に答える 2

2

たぶん問題はプロキシtype: 'jsonp'ですか?

あなたの例では私は見えjsonjsonp、あなたのAPI URLは同じサーバー上にあるので、json代わりに使用しないのはなぜjsonpですか?

例:

var storeDef = Ext.create('Ext.data.Store', {
    id: 'storeDef',
    model: 'Olvldefnition',
    proxy: {
        type: 'ajax',
        api : {
            read : 'definition/view.action'
        },
        reader: {
            type: 'json',
            root: 'data',
            idProperty: 'defKey',
            successProperty : 'success',
            messageProperty : 'message'
        }
    }
});
于 2012-05-15T11:32:24.993 に答える
0

どこかに単純な構文エラーがあると思います。JSONデータの解析とは何の関係もありません。

于 2012-05-15T11:19:07.333 に答える