我试图在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.');
}
}
});
答案 0 :(得分: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.');
}
});
希望有所帮助 -