1
我尝试将页面重定向到1stlink.php
以及URL参数。但是在重定向用户之后,该变量不会显示在页面上。重定向页面不显示url值
为什么不能在我的重定向页面中获得variable
的值?
<html>... <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
$('#btn').click(function() { // The `$` reference here is a jQuery syntax. So we are loading jquery right before this script tag
var textval = $('#textcat').val();
window.location = "1stlink.php?variable=" + textval;
});
</script>
1stlink.php
<?php
echo $_GET['variable'];
?>
:你总是应该添加任何到URL之前使用
encodeURIComponent
这个问题可能是由于你的页面由于连接问题从另一个站点加载jquery失败。尝试下载jquery源代码并让您的网页从您的网站加载它。此外,要获得更清晰的想法$ _GET ['变量']测试,看看它的值是否为空。您可以在PHP中使用is_null()或$ _GET ['variable']!= null。 – slevy1重定向是否发生?确保您将有效的值传递给URL。 'window.location =“1stlink.php?variable =”+ encodeURIComponent(textval);'在你的PHP页面上,尝试'var_dump($ _ GET)'而不是'echo'。 – miken32
谢谢@ miken32 encodURIComponent的工作 – prog