dougao1542 2016-11-07 21:35
浏览 50

使用AJAX和PHP登录Intel XDK,MySql不起作用

I have this code

            $("#btn_log").click(function(){
                var frm=$("#frm_usuario").serialize();
                    $.ajax({ 
                    type:"GET",
                    url:"http://www.MYWEB.com/cstapp/validarUsuario.php",
                    data:frm,
                    dataType:'json',
                    success:function(response){ 
                        if(response.estado==1){
         window.location.href = response.url;                      
                        } else { 

         alert("ERROR");                            
                        }  
                    } 
                }); 

            });

And the PHP for get it

    $usuario= strtolower(htmlentities($_REQUEST["txt_usuario"], ENT_QUOTES));       
    $clave=htmlspecialchars(trim($_REQUEST['txt_clave']));

    $sql="SELECT * FROM table WHERE usuari='$usuario' AND passw='$clave'";
    $result = mysql_query($sql,$connection) or die('La consulta falló'.mysql_error());
    $tmp_usu="";
    $tmp_clave="";

    $arr_rpta=array();
    while($obj = mysql_fetch_object($result)) {
     $tmp_usu=$obj->nomusuari;
     $tmp_clave=$obj->passw;
     $tmp_id=$obj->id;
    }
    if(($tmp_usu==$usuario)&&($tmp_clave==$clave)){

       $arr_rpta=array("estado"=>1,"url"=>"segunda.html","id" => $tmp_id);
    }else{  
       $arr_rpta=array("estado"=>"0","url"=>"fallo en ellogin");   
    }
    echo json_encode($arr_rpta);

Ok, this works on my computer. Not works on XDK compilation apk and not works on a XDK simulator.

Has anyone any suggestions? Thank you very much

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?