Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change page without refresh a div into the page

Hi i'm looking for a tutorial for understand how i can create a page with a div that isn't refreshed when the page url changes.

Ex. The facebook chat isn't refreshed when i move from an url to another.

Thanks

like image 357
Luca Romagnoli Avatar asked Nov 14 '22 04:11

Luca Romagnoli


1 Answers

AJAX is definitely being used, although it may not seem like it because the actual URL is changing. Most AJAX apps just change the hash part of the URL (somesite.com/page/#feature1).

I don't know exactly what Facebook is doing as I haven't studied the app, but I would guess that they are using HTML5 history.pushState() to change the URL so that if you bookmark it or reload, it will go to the same place. I see that @Felix already mentioned this in a comment.

Take a look here for more help:

Is there a way to change the browser's address bar without refreshing the page?

There are lots and lots of resources on using AJAX. I personally use jQuery and find that it makes much of this quite easy. Here's a tutorial that might help:

http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/

like image 189
Tauren Avatar answered Dec 19 '22 22:12

Tauren