繁体   English   中英

PHP $ _GET无法与JQuery Mobile一起使用

[英]PHP $_GET not working with JQuery Mobile

我正在使用JQuery Mobile和PHP编写应用程序。

问题:当我尝试从一个JQuery移动页传递值时(例如,使用Ajax和PHP从#page1传递到#page2),$ _ GET不会在URL中检索值。

该网址将如下所示:

对myApp /#PAGE3?FID =牛奶+奶酪+黄油

PHP无法获取"?fid="

我认为这是使用JQuery mobile(单个页面)设置URL的方式存在问题。 解决这个问题的任何帮助将不胜感激。 谢谢

我的Ajax(摘要):

request.onreadystatechange = function(){
    if((request.readyState==4) && (request.status==200 || request.status == 304)) {
        if(request.responseText!= undefined){
            window.location.replace('#page3?fid='+request.responseText+'');
        }
    }
}  

第一个PHP页面:

<?php 
    include '../connect/connect.php';
    $ingredients = $_POST['ingredients'];
    if (empty ($ingredients) === false){
        foreach($ingredients  as $key => $ingre){
            if ($ingre != 'undefined'){
                $refine = substr($ingre, "4");
                $refined = mysqli_real_escape_string($con, $refine);
                echo $refined;
            }
        }
    }
?>

第二个PHP页面:

<?php
    if (isset($_GET['fid'])) {
         echo 'yes';
    } else {
        echo 'no';
    }
 ?>

哈希(一切都从#字符开始)不会发送到服务器。 哈希应位于URL的末尾,即所谓的查询字符串之后,因此正确的URL为:

myApp/?fid=Milk+Cheese+Butter#page3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM