how to change url on function load with jquery / ajax
didn't found any help wit开发者_如何学Ch the search...
I'm going to do something like loading the content of an external php-file into a div container on my index.php; to do so, I added a javascript call into the href of my hyperlinks that calls a function like this:
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;
}
}
well actually this works fine, but now I'm searching for a possibility to change the url of my index.php after loading such a content php file... for example it should be possible to safe a bookmark for index.php#profile index.php#einstellungen
does anybody has got a hint for me to search for or done something like that??? help appreciated!
(furthermore those external php file will include complex php code, mysql requests and so on...)
Look into window.location.href.hash. You should be able to use that to set the hash value on the URL. Look into http://plugins.jquery.com/plugin-tags/hash and http://benalman.com/projects/jquery-bbq-plugin/
精彩评论