开发者

Sencha Touch - Error - JSON Recovery

I contact you because I'm in a deadlock. I try to get data from a extern web service with "ScriptTag" but it does not work because the web service returns simple json format (No JSONP).

Do you know if there is a another way to retrieve json using sencha ?

var helloWorld = new Ext.Application({

Parking: Ext.regModel('Parking', {
    fields:[
        {name:'parkingName'},
        {name:'latitude'},
        {name:'longitude'},
        {name:'mapUrl'}
    开发者_如何学C],
}),

launch: function() {
    this.tabs = new Ext.TabPanel({
        fullscreen: true,
        dockedItems: [{xtype:'toolbar', title:'JSON Recovery'}],
        tabBar: {
            ui: 'light',
            layout: {
                pack: 'center'
            }
        },
        items: [
            {cls:'Page1', title:'Page1', html:'Page1'},
            {
                cls: 'list',
                title: 'Page2',
                xtype: 'list',
                loadingText: 'Chargement',
                itemTpl:'<div>{parkingName}</div>',
                store: new Ext.data.Store({
                    autoLoad:true,
                    model: 'Parking',
                    proxy: {
                        type: 'scripttag',
                        url :  'http://walker.hotcity.lu/hotcity-central-server/webresources/parking/json?format-version=1_0&client-type=iPhone',
                        reader: {
                            type: 'json',
                            root: 'remoteObject'
                        },                      
                    }
                }),
                
            },
        ],
                        
    });

}

});

warning : Resource interpreted as Script but transferred with MIME type application/json.

error : Uncaught SyntaxError: Unexpected token :

Thank You.

Kevin.


What you are looking for is the Ajax Proxy. There are some examples in the docs about how to use it, and how to configure it. The default reader is JSON so as long as your model matches up with the information retrieved via JSON then you will be alright.

The other thing you should be aware of is that, JSONP can get around cross site scripting, but if you are not deploying to the walker.hotcity.lu domain, then the browser will not allow the request due to the same origin policy. The server will have to respond with the proper CORS headers to allow your app to access the data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜