我有一个应用程序使用Backbone.js
,我使用Cordova构建此应用程序。该应用程序做了一个登录请求,这在iOS和Web浏览器上正常工作,所以我知道该方法存在并正在工作。但是,对于Android,它返回一个“POST 404(未找到)”错误,即使代码是相同的。为什么它在iOS上而不是在Android上运行?它会是代码问题还是构建问题?Model.save在Android上引发404错误
这是我的要求:
return $.ajax(params);
//params
Object {headers: Object, type: "POST", dataType: "json", data: "
{"email":"[email protected]","password":"password"}"…}
crossDomain :true
data :"{"email":"[email protected]","password":"password"}"
dataType :"json"
error :function (resp)
headers: Object
Accept : "*/*; charset=utf-8"
Content-Type :"application/json"
isLoginRequest: true
parse: true
processData: false
success: function (resp)
type :"POST"
url :"http://ip_address:port/api/login"
validate: true
__proto__ :Object
//method
var context, errors = [], model = new Model({}, {url: Config.login});
model.set(data);
if(!model.isValid()){
context = _.extend({
errors: model.validationError
}, data);
this.renderLoginView(context);
return;
}
model.save(null, {
isLoginRequest: true,
success: _.bind(this.loginSuccess, this),
error: _.bind(function(xhr, textStatus){
//this is where it goes
errors = {name: 'email/password', message: 'Invalid Username or Password'};
context = _.extend({
errors: errors
}, data);
this.renderLoginView(context);
},this)
});
您确定您使用的IP是否正确?它是真实的IP地址还是本地地址? –
这是正确的IP地址,相同的代码在iOS上工作正常 –
也许iOS连接到互联网的另一种方式? –