【发布时间】:2017-03-27 04:30:03
【问题描述】:
我无法连接到我的数据库,因为我的 URL 被拒绝。我要访问的网址是这样的:
我有一些结构相同的 url,我已经在我的 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');
}
谢谢。
【问题讨论】:
-
您遇到了哪些错误?
-
我解决了,问题是没有添加白名单插件。我不知道为什么...我在我的应用程序目录上用这个 bash 代码解决了:cordova plugin add github.com/apache/cordova-plugin-whitelist.git
标签: php cordova cordova-plugins whitelist