duan0818 2011-12-15 21:31
浏览 23
已采纳

获取查询字符串php - jquery - #?id =

I am really stuck and was wondering if someone could lend a hand please,

i know how to get a query string, thats not a problem,

however, I have links that use jquery to fade out the content and load the new content via links,

usage example below - class="link2" is a reference for the jquery to do what it does lol

<a href="#?id=2" class="link2">click here</a>

in the href i have to have the # first to stop the page from loading if you get what i mean,

now when i try and get the query string id=2 it says none as there is a # first, there is probably a simple fix for this but i must just be missing it, i have searched and searched but still cant find the answer

----------------------edit------------------------------ this is what i am trying to do,

enter page, sql query runs to display all the reports click a report and the jquery hides "contmain" and shows "contreports" now a new sql query runs to display the report based on the "id"

now usually i can just get this information from the url and clean it up, hovever as i have jquery running i need to have the "#" for the href so the page does not reload and the jquery can run, but now this is stopping me from being able to retrieve the url query,

Interstellar_Coder he seems to have the right idea, passing it in the background

  • 写回答

2条回答 默认 最新

  • doubai9014 2011-12-15 21:37
    关注

    Although i don't fully understand what you're doing, i'm guessing it would be better to store your querystring as a data attribute.

    <a href="#" data-id="2" class="link2">click here</a> 
    

    Then in your jQuery function.

    $('.link2').click(function(e){
        var queryString = $(this).data('id'); 
        e.preventDefault();   // prevent the default action
    }); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题