[英]$_GET Loading Elements/Data From Another Page
I have a page that shoots over to a script, loads my elements and data, then comes back. 我有一个页面可以浏览到脚本,加载我的元素和数据,然后返回。 The problem being that
?name=steve
obviously doesn't make the transition from scripts.php to load.php. 问题是
?name=steve
显然无法实现从scripts.php到load.php的转换。 How am I able to use $name = $_GET['name'];
我如何使用
$name = $_GET['name'];
in load.php
? 在
load.php
? Also is this code below bad? 下面的这段代码也是不好的吗? I was told that this is over complicating it.
有人告诉我这太过复杂了。
function showInfo(str) {
if (str == "") {
document.getElementById("rankhint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("rankhint").innerHTML = xmlhttp.responseText;
$(document).foundation();
}
};
xmlhttp.open("GET","load.php?q="+str,true);
xmlhttp.send();
}
}
You can pass the query string through to the next page. 您可以将查询字符串传递到下一页。
Assign it to a variable and then append to the URL: 将其分配给变量,然后附加到URL:
var qs = "<?php echo $_SERVER['QUERY_STRING']; ?>";
xmlhttp.open("GET","load.php?"+qs+"&q="+str,true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.