开发者

retrying a store load with a different URL on exception (use external URL)

I have a system that has two servers one active and one passive. I'm writing a single page application using extjs4 that use data from the server. When I get an exception from a store.load() I would like to retry with a different URL. I have this code below, that sends succesfully the command to the new URL (the passive server), but instead of using GET use OPTIONS. Also for some reason the new command results in an exception as well, what cause an infinite loop.

Any idea what I'm doing w开发者_JS百科rong or other way to accomplish retryng the http command to a different URL?

var store = Ext.create('Ext.data.Store', {
        pageSize:25,
        autoLoad: false,
        model: 'VsaGui.VPool',
        proxy: {
            type: 'rest',
            url: activeMgmtUrl + 'vsacmd.xml?cmd=list_vpools',
            reader: {
                totalProperty: 'vpools-count',
                type: 'xml',
                record: 'vpool'
            },
            listeners: {
                exception: function(proxy, response, operation, eOpts ){
                            p = store.getProxy();
                            p.url = passiveMgmtUrl + 'vsacmd.xml?cmd=list_vpools';
                            p.read(operation);
                        }

            }    
        }         

    });

I did some research and it seems that the problem is not in the code but the fact that in my retry I access and external URL (the passiveMgmtUrl = "http://192.168.1.54/"). This is why Firefox send the OPTIONS method and under IE9 the second request end up with "Access Denied". So any idea on how to connect to an external URL?


If your second request is to another domain, you must use jsonp as your proxy as opposed to ajax (rest is just a specialized version of ajax). Jsonp will allow you to make requests to external domains, otherwise you are locked into the server's domain.

See http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.JsonP for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜