开发者

error : invalid label when i try to get json from url SENCHA TOUCH

开发者 https://www.devze.com 2023-01-28 04:01 出处:网络
I try with the following code and i get error: invalid label Ext.util.JSONP.request({ url: \'http://demo.webfactory.mk/\',

I try with the following code and i get error: invalid label

Ext.util.JSONP.request({
            url: 'http://demo.webfactory.mk/',
            callba开发者_如何学CckKey: 'callback',
            params: {
                action: 'retrieve',

            },
            callback: function(data) {
                console.log('Inside data');
                var dataarray = data.result;
                console.log(dataarray);

            }

    });


You can also use Ajax request instead of JSONP, below is the code sample. This works for me.

Note that you cannot make cross domain Ajax calls, in chrome so u cant test in chrome. You need to deploy your Sencha script to the same Web server you are accessing. But All mobile browser supports this cross domain Ajax calls.

Go ahead and implement the same.

Ext.Ajax.request({
        url: reqUrl,
        defaultHeaders : 'application/json',
        success : function(response, opt) {
            dataarray = Ext.decode(response.responseText);
            //App.views.viewport.reveal('nextScreen');
        },
        failure : function(response, opt) {
            Ext.Msg.alert('Failed', response.responseText);
        }
    });
0

精彩评论

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