0

我正在尝试在 sencha 中调用注册 webservive。当我在浏览器上调用它时,它似乎没问题。但是我在应用程序中调用它会给出以下错误。请任何人帮助我。

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

这是我的代码

 Ext.Viewport.setMasked({xtype:'loadmask',message:'your custom loadmask'});
    Ext.data.JsonP.request({
        url: 'http://XXX.XXX.com/api/users/?',
        params: {

            first_name:'mohit',
            last_name:'bisht' ,
            city:'ramnagar',
            state:'UK',
            phone:'9073467465',
            email:'test@test.com',
            password_digest:'123456',
            op:'s'
        },
        success : function(response,opts) {
            Ext.Viewport.setMasked(false);

            console.log(response.status);



        },
        failure : function(response,opts) {
            Ext.Viewport.setMasked(false);
            if (response.timedout) {
                Ext.Msg.alert('error', 'Request to server timed out.');
            }
            else if (response.aborted) {
                Ext.Msg.alert('error', 'Request Aborted by server.');
            }
            else {
                Ext.Msg.alert('error', 'Invalid Request to server.');
            }
        }
    });
4

1 回答 1

0

你确定服务支持jsonp吗?您可以尝试使用 ajax 请求:

Ext.Viewport.setMasked({xtype:'loadmask',message:'your custom loadmask'});
Ext.Ajax.request({
    useDefaultXhrHeader: false,
    cors: true,
    url: 'http://XXX.XXX.com/api/users/?',

    params: {
        first_name:'mohit',
        last_name:'bisht' ,
        city:'ramnagar',
        state:'UK',
        phone:'9073467465',
        email:'test@test.com',
        password_digest:'123456',
        op:'s'
    },

    success : function(response,opts) {
        Ext.Viewport.setMasked(false);
        console.log(response.status);
    },

    failure : function(response,opts) {
        Ext.Viewport.setMasked(false);
        if (response.timedout) Ext.Msg.alert('error', 'Request to server timed out.');
        else if (response.aborted) Ext.Msg.alert('error', 'Request Aborted by server.');
        else Ext.Msg.alert('error', 'Invalid Request to server.');
    }
});

希望能帮助到你-

于 2013-09-27T12:00:20.380 回答