使用php $ _GET加载jQuery不起作用

i want to send Get when the link clicked to receive the result in php code and this what happened this in php file working perfect

        <html>
    <a class="cc" href="#">click me</a>
    <script src="js/jquery.js"></script>
    <script type="text/javascript">
    
        $(document).ready(function () {
    
            $(".cc").click(function () {
                $(".body").load('page.php ')
            })});
    
    </script>
    
    <section class="body"></section>
    
    </html>

but when i put GET to the href didn't work just Flashing content

<html>
    <a class="cc" href="?id=1">click me</a>
    <script src="js/jquery.js"></script>
    <script type="text/javascript">
    
        $(document).ready(function () {
    
            $(".cc").click(function () {
                $(".body").load('page.php ')
            })});
    
    </script>
    
    <section class="body"></section>
    
    </html>

</div>
duaner1634
duaner1634 您是否需要在page.php中使用$_GET['id']以用于返回的内容?如果是这样,除了Praveen的答案之外,你需要将id=1添加到.load('page.php')....就像.load('page.php?id=1')或.load('page.php文件'+$(本).attr('href'属性))
大约 2 年之前 回复

1个回答

In the second case, you really need to stop the <a> from following the link.

$(document).ready(function() {
  $(".cc").click(function(e) {
    e.preventDefault();
    $(".body").load('page.php');
  });
});
douju1953
douju1953 哈哈谢谢! :)
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐