【问题标题】:how to change url on function load with jquery / ajax如何使用 jquery / ajax 更改函数加载的 url
【发布时间】:2011-12-05 11:54:47
【问题描述】:

没有找到任何关于搜索的帮助...

我将做一些事情,比如将外部 php 文件的内容加载到我的 index.php 上的 div 容器中; 为此,我在超链接的 href 中添加了一个 javascript 调用,它调用如下函数:

function contentloader(e){
switch(e){          
  case "profil":
    $("#content").load("profil.php");
    this.href('#profil');
    break;   
  case "einstellungen":
    $("#content").load("einstellungen.php");
    break;
  case "freunde":
    $("#content").load("freunde.php");
    break;     
}   

}

实际上这很好用,但现在我正在寻找一种可能性,在加载这样一个内容 php 文件后更改我的 index.php 的 url... 例如,应该可以为 index.php#profile index.php#einstellungen

有没有人提示我搜索或做类似的事情??? 帮助表示赞赏!

(而且那些外部的php文件会包含复杂的php代码、mysql请求等等……)

【问题讨论】:

    标签: php javascript jquery hashtag


    【解决方案1】:

    查看 window.location.href.hash。您应该能够使用它来设置 URL 上的哈希值。查看http://plugins.jquery.com/plugin-tags/hashhttp://benalman.com/projects/jquery-bbq-plugin/

    【讨论】:

    • 感谢您的帮助!我试过这个: function contentloader(e){ switch(e){ case "profil": $("#content").load("profil.php"); var Ziel = "!profile"; window.location.hash = 齐尔;休息;但是有些事情我自己没有得到答案-例如直接索引 index.php#!profil 它正在打开 index.php 但没有加载 profil.php 的外部内容 - 这怎么可能,请耐心等待,我是编程新手和类似的东西:D 在此先感谢!
    猜你喜欢
    • 2011-02-17
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-15
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    相关资源
    最近更新 更多