0
我無法連接我的數據庫,因爲我的網址被拒絕。我想要訪問的網址是:科爾多瓦白名單不允許訪問我的服務器
我有一些網址相同的結構,我在我的config.xml文件中試過,但沒有奏效。
<access origin="*" />
<access origin="http://192.168.0.16" subdomains="true" />
或
<access origin="http://192.168.0.16/*"/>
這是我創建的路徑和調用的函數連接到我的數據庫的完整代碼:
function pullUser(userName,apodo,secondName,lastName,pass1,userMail){
var method='GET';
var url = appConstants.requestpullUserURL();
//alert('cogidaUrl: '+ url);
var path = url + "?nombre="+userName+"&apodo="+apodo+"&apellido1="+secondName+
"&apellido2="+lastName+"&email="+userMail+"&clave="+pass1;
console.log(path);
//alert('El path es: '+ path);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
//alert('onready. readyState:'+xhr.readyState+' status: '+xhr.status);
if(xhr.readyState == 4 && xhr.status == 200){
resp = xhr.responseText;
//alert('Registro completado');
transitionLog();
}else{
//alert('devuelve false');
return false;
}
}
xhr.open(method, path, true); //Creamos la peticion
resp = xhr.send(); // FALLA AQUI SIN SERVER
alert('despues del send');
}
感謝。
什麼是您遇到的一些錯誤? – johnborges
URL被白名單阻止:http://192.168.0.16/checkUser.php?apodo=k&clave=k – Asier
我解決了,問題是沒有添加白名單插件。我不知道爲什麼...我用這個bash代碼解決了我的app目錄:cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git – Asier