weixin_33743248 2015-11-06 17:17 采纳率: 0%
浏览 21

如何调试Ajax代理

I'm trying to create simple crud application with ExtJs6 and Lumen as backend PHP framework. I created extJS app following standard documentation. My extJS is running on http://localhost:1841/ using build in sencha server (sencha app watch).

When I changed

proxy: {
    type: 'memory',
    reader: {
        type: 'json',
        rootProperty: 'items'
    }
}

on

proxy: {
    type: 'ajax',
    url: 'data',
    reader: {
        type: 'json',
        rootProperty: 'items'
    },
    autoload: true,
    listeners: {
        exception: function (proxy, response, operation) {
            Ext.MessageBox.show({
                title: 'REMOTE EXCEPTION',
                msg: operation.getError(),
                icon: Ext.MessageBox.ERROR,
                buttons: Ext.Msg.OK
            });
        }
}

and added those listeners to my proxy and store objects

   beforeLoad: function(store, operation){ // 1st; no data items
        console.log('beforeLoad');
        console.log(store.data.items);
    },
    dataChanged: function(store){ // 2nd; data items populated, controls still empty

        console.log('dataChanged');
        console.log(store.data.items);
    },
    load: function(store, records, success){ // 3rd; data items populate, controls show data
        console.log('load');
        console.log(store.data.items);
    }

I hoped to see some MessageBox with errors or some messages in a browser console, but there weren't either. Btw, there's nothing on http://localhost:1841/data URL. So, two main question:

  • Why my console.log(.. code and MessageBox aren't working?

  • Is there a way to tell sencha built in server return some sample json data on specific url?

PS: I do sencha app build to compile js and then use it in PHP app, which runs on another localhost's port and, obviosly, returns some data on data URL. But it's still not showing it in my app. With memory proxy it works fine.

Full store class: https://github.com/jehaby/Cognitive/blob/master/Cognitive/app/store/Personnel.js Full repository: https://github.com/jehaby/Cognitive/ ExtJS app created here: https://github.com/jehaby/Cognitive/Cognitive

  • 写回答

0条回答 默认 最新

    报告相同问题?