Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将数据从extjs中的ajax响应加载到内存中_Extjs - Fatal编程技术网

将数据从extjs中的ajax响应加载到内存中

将数据从extjs中的ajax响应加载到内存中,extjs,Extjs,我的json数据如下所示 // //var data = { // // // // // "success": true, // "users": [ // {"id": 1, "name": 'Ed', "email": "ed@sencha.com"}, // {"id": 2, "name": 'Tommy', "email": "tommy@sencha.com"}, // //

我的json数据如下所示

//
//var data = {
//      
//
//      
//      
//     "success": true,
//     "users": [
//         {"id": 1, "name": 'Ed',    "email": "ed@sencha.com"},
//         {"id": 2, "name": 'Tommy', "email": "tommy@sencha.com"},
//         
//           {"id": 3, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           {"id": 4, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           {"id": 5, "name": 'Tommy', "email": "tommy@sencha.com"},
//       
//         {"id": 11, "name": 'Ed',    "email": "ed@sencha.com"},
//         {"id": 12, "name": 'Tommy', "email": "tommy@sencha.com"},
//         
//           {"id": 13, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           {"id": 14, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           {"id": 15, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           
//             {"id": 21, "name": 'Ed',    "email": "ed@sencha.com"},
//         {"id": 22, "name": 'Tommy', "email": "tommy@sencha.com"},
//         
//           {"id": 23, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           {"id": 24, "name": 'Tommy', "email": "tommy@sencha.com"},
//           
//           {"id": 25, "name": 'Tommy', "email": "tommy@sencha.com"},
//       
//         
//     ]
//  }       
//           







// this my store in extjs


var store = Ext.create('Ext.data.Store', {
    model: 'AM.model.User',
        pageSize : 10,

        autoLoad: true,
       data:data,

        proxy: {
            type: 'memory',

            enablePaging: true,
            reader: {
                type: 'json',
                root: 'users',
                 totalProperty : 'total'
            }
        },








    });

// ajax request to call json data in json file

Ext.Ajax.request({
       url: 'app/data/users.json',

       success: function(response, opts) {
          var obj = response.responseText;


          store.loadData(resp.responseText, true); 

       },
       failure: function(response, opts) {
          console.log('server-side failure with status code ' + response.status);
       }
    });



// this is my view .

Ext.define('AM.view.user.List' ,{
    extend: 'Ext.grid.Panel',
    alias: 'widget.userlist',

    title: 'All Users',





    initComponent: function() {

        Ext.create('Ext.grid.Panel', {
          title: 'Column Demo',
          store:store,
          columns: [
         {header: 'ID',  dataIndex:'id',flex:1},
              {header: 'Name',  dataIndex:'name',flex:1},
              {text: 'Email',  dataIndex:'email',flex:1},

          ],

         renderTo:'example-grid',
         width: 350,
         height: 285,
      dockedItems: [{
          xtype: 'pagingtoolbar',
          store: store,   // same store GridPanel is using
          dock: 'bottom',
          pageSize: 10,
          prependButtons: true,
          displayInfo: true
      }],






          renderTo: Ext.getBody()
        });


        store.loadPage(1);
      this.callParent(arguments);
  }



});

我将使用分页。为此,我需要json数据。我从ajax响应中获得的json数据。如何将ajax响应json数据加载到内存中。有人能帮我吗。我走的路是对的还是错的我不知道没有人能帮我

resp.responseText返回一个简单的字符串。
请改用JSON.parse(resp.responseText)。

可能重复的-1我没有得到答案,这不是两次发布同一个问题的原因。您应该尝试重构您的问题,而不是对您的原始问题有答案,特别是建议不要使用Ext.Ajax.request,而是使用内置的存储/代理基础结构的问题。你做到了吗?我知道buddy.ajax调用用于将数据加载到store中,但不是内存中。如果我在ajax中使用代理,那么如何在代理中使用内存。你能给我@saki提供示例或代码帮助吗