我想通过 jQuery 将 ID 传递给 urlstring 而不刷新 jQuery 和#
标签,以便我可以通过 php$_get['ID']
函数获取 ID。
但问题是
- 如果我使用
#
,页面没有得到刷新,但是 PHP 确实从 url 中选择了 ID。 - 如果我不使用#,那么 php 会选择 ID,但页面会刷新。
我想在不刷新页面的情况下将 id 传递给 php。
//javascript
function com(id) {
location.href = '#?ID=id'; //by this way way,page doesn't refresh, ID appears in the url string but ID is not picked by PHP as # is there
// location.href = '?ID=id'; this way way, ID appears in the url string , ID is also picked by PHP as # is there.But page get refreshed.
$.ajax({
type: "Post",
url: "getdata.php",
async: true,
cache: false,
success: function(data) {},
});
}
//php for getdata.php
<?php echo $_GET['ID']; ?>