douyong5476 2016-11-13 11:46
浏览 76

Cordova WhiteList不允许访问我的服务器

I can not connect with my database because my URL is rejected. The url i want to access is this:

http://192.168.0.16/checkUser.php?nombre=asi&clave=1234

I have some urls with same structure, and i have tried this in my config.xml file but did not worked.

<access origin="*" />
<access origin="http://192.168.0.16" subdomains="true" />

or

<access origin="http://192.168.0.16/*"/>

This is the complete code where i create the path and call the functions to connect to my database:

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');
}

Thanks.

  • 写回答

1条回答 默认 最新

  • du1843 2016-11-22 09:41
    关注

    I solved it, adding the whitelist pluggin. I don´t know why when i created the project did not added itself. This bash code on my app directory solved it: cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line