Android PhoneGap ajax(json调用)
我有一个Android应用程序,其中包含对我的远程服务器的ajax json调用。我已经用eclipse,一个模拟器(Ripple)测试了这个应用程序,并在本地服务器的浏览器中测试了ajax脚本。所有的测试都能很好地工作,但当我将我的应用程序上传到PhoneGap Build并在手机上测试apk文件时,ajax调用返回状态0。我做错了什么?仿真器和apk之间会有区别吗 Ajax调用:Android PhoneGap ajax(json调用),android,jquery,ajax,json,cordova,Android,Jquery,Ajax,Json,Cordova,我有一个Android应用程序,其中包含对我的远程服务器的ajax json调用。我已经用eclipse,一个模拟器(Ripple)测试了这个应用程序,并在本地服务器的浏览器中测试了ajax脚本。所有的测试都能很好地工作,但当我将我的应用程序上传到PhoneGap Build并在手机上测试apk文件时,ajax调用返回状态0。我做错了什么?仿真器和apk之间会有区别吗 Ajax调用: var formData = $("#form-id").serialize(); $.ajax({ url:
var formData = $("#form-id").serialize();
$.ajax({
url: "https://mydomain.com/file.php",
data: formData,
type: 'POST',
dataType: 'json',
timeout: 5000,
success: function(data){
if(data['login'] == 'correct' && data['token'] != 'undefined' ){
window.localStorage["token"] = data['tokenMyMen'];
notifyAlert('Login correct', 'Login');
}else{
notifyAlert('Login incorrect', 'Login');
}
},
error: function(x,e){
if(x.status==0){
notifyAlert('You are offline!!\n Please Check Your Network.', 'Error');
}else if(x.status==404){
notifyAlert('Requested URL not found.', 'Error');
}else if(x.status==500){
notifyAlert('Internel Server Error.', 'Error');
}else if(e=='parsererror'){
notifyAlert('Error.\nParsing JSON Request failed. '+x.status, 'Error');
}else if(e=='timeout'){
notifyAlert('Request Time out.');
}else {
notifyAlert('Unknow Error.\n'+x.responseText, 'Error');
}
}});
config.xml具有
远程服务器具有:
if($this->user->login($username, $password)){
$token = $this->user->getProperty('token');
$createArray = array();
$createArray['login'] = 'correct';
$createArray['token'] = $token;
$record = $createArray;
echo json_encode($record);
}else{
$record = array('login' => 'incorrect');
echo json_encode($record);
}