Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Facebook work with AJAX?

How does Facebook work with AJAX? Thanks a lot!

Before

http://www.facebook.com/#/events.php

Now

http://www.facebook.com/?sk=events
like image 395
Ryan Zygg Avatar asked Jan 21 '23 03:01

Ryan Zygg


1 Answers

It's still doing the hash URLs and AJAX requests under the covers (though it fails fairly gracefully as well), it's just using some HTML5 features with history to push a different URL to your address bar.

If you view the site in an older browser that doesn't support this yet (everything besides Chrome at the moment) you'll still see the #!/path format (for Google indexing) on the URL, for example:

http://www.facebook.com/home.php?#!/?sk=events

Specifically it's using history.pushState() and history.replaceState() added in HTML5, if the browser supports it to display another (direct) URL in your address bar.

like image 175
Nick Craver Avatar answered Feb 01 '23 10:02

Nick Craver