Wednesday 30 December 2009

AJAX - Theory

OK so one of the first thing that I would usually ask is what is AJAX. Well it stand for Asynchronous JavaScript And XML which basically means interacting with a web page using JavaScript in an Asynchronous way i.e. the JavaScript interacts with the webserver to change the contents of the static HTML page sort of on the fly. That been said the web browser interacts with the web server using a thing called HTTP requests (HyperText Transfer Protocols) and what this basically does is that the user enters a URL and the web browser sends a request to the web server requesting the contents of the page. The web server responds with by sending the marked up page with any client side scripts. Please note that for server side scripts such as PHP the scripts are executed on a PHP enabled server before the markup is sent back to the browser. Once the brower recieves the marked up page(HTML) and the scripts it executes the scripts and displays the web page to the user following the rules that have been set for it in the CSS and stuff.

Now AJAX is a funny concept, it is JavaScript in the sence that it is executed on the client side but it also communicates with the server to load bits and pieces of the page. The communication is usually triggered by a user action such as a click on a button or the pressing of a key on the keyboard or basically anything that JavaScript can acknownledge. The requests that are being made are through a method called XMLHttpRequest. Now traditionally this would mean only getting XML from the server but from what I understand you could ask for anything to be imported like XHTML.

Next up will be how to make a request and please do correct me if I go wrong anywhere :).

No comments: