我正在使用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';
}
?>
答案 0 :(得分:1)
散列(从#
字符开始的所有内容)不会发送到服务器。哈希应该位于url的末尾,在所谓的查询字符串之后,所以正确的URL将是:
myApp/?fid=Milk+Cheese+Butter#page3