November 7, 2013

AJAX, States, and Pushstate()

AJAX stands for Asynchronous Javascript and XML. Many popular websites make use of AJAX, for example Google and Twitter. To understand why it's being used, we have to understand how the traditional World Wide Web was meant to be built. The web was intended to work like this: you use a web browser application (eg. Internet Explorer, Chrome, Firefox, Safari) on your computer to visit a web page, by giving the browser that page's URL address (eg. http://www.google.com). The browser, or client, connects to a web server via the internet and requests that web page, which is merely a text file, specifically an HTML file. That server serves that file back to the client browser, and the browser displays that page, also requesting any additional files such as images needed to completely display that page. You can then click on a hyperlink to visit another web page, and your browser goes and connects to whatever web server is that file is stored on to get that page. But as the web has matured, websites have gotten more complicated, bigger, and more visual, and the basic HTML web model has become obsolete. We moved from mostly text-based pages to websites consisting of many web pages, all with consistent visual elements (eg. logo in the top left, a navigational menu along the top or side, a footer) which are there to make the web more user friendly. We've also developed new technologies, like CSS, Javascript, and PHP, to supplement our basic HTML websites, and one of these technologies is AJAX.