doutong7216 2014-10-16 07:47
浏览 11

网页不应该刷新

I need a webpage should not refresh while clicking, but it should pass id of that link.

<?php echo "<a href='http://localhost/ss/index.php?albumid={$id}#photo'><img src=http://localhost/ss/admin/html/".$p['path']." class='img-responsive' alt='' data-toggle='modal' data-target='.bs-example-modal-lg1'></a>";

<?php if(isset($_GET['albumid'])) $mid = $_GET['albumid']; ?>

I have tried ajax, but it is not working. Is it possible? Can u please help me?

  • 写回答

1条回答 默认 最新

  • dongxiai3003 2014-10-16 10:15
    关注

    It is possible to pass id, and then make a ajax call so page refresh can be avoided.

    Following is the code, how you can pass the id and make use of jQuery for ajax call

    <div id='link1'><a href='yourfilename.php?id=1'>abc</a></div>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
      $("#link1").click(function(){
            $.ajax({url:"abc.php",success:function(result){
          //Code after the success of ajax call
        }});
      });
    });
    </script>
    

    It will surely help you dear

    评论

报告相同问题?

悬赏问题

  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败