dtxooq1020 2012-08-25 01:28
浏览 71

使用Ajax / Javascript更改PHP URL变量

I have made up a webpage on a private server as part of a full website redesign. The page calls up files such as contact.php with AJAX code to show the contents within a DIV layer, so that the actual page is still index.php but looks like a contact page.

What I would like to do is have a function that, when such links to make the AJAX call are clicked, will dynamically change the URL so that if somebody clicks the Contact link the page URL looks like index.php?page=contact (as an example).

Facebook has the sort of system I am looking to usewhen you click on a photo from the news feed and then change to another photo from the same user/gallery. I don't want something that just changes the URL from a hash tag (#), as that just adds complication to the design, whereas one that puts a PHP variable into the URL simply means I can write a PHP code to include the file directly if the variable is set.

Thanks.

  • 写回答

1条回答

  • dtq26360 2012-08-25 01:51
    关注

    Have you considered using History.js?

    It sounds like you're wanting to essentially use $_GET vars to dictate what's served on the page... kind of. Although it also looks like you're calling in that content via ajax based on this var, so php is mostly irrelevant in this scenario since it would be js parsing the url and deciding what to ajax in. History will do all of this for you. It reads the url as a state and serves as you tell it to. Obviously it's not that simple, but if you read the docs it's pretty clear how to use it. https://github.com/balupton/jquery-history

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料