我有一個應用程序使用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連接到互聯網的另一種方式? –