Easy Ajax Programming – FOR BABIES!
Dec 10th, 2009 | By NavGupta-Abhiware | Category: Technical Knowledge BaseListen, for those of you who have programmed a website even a little bit, you’ll have heard of something called Ajax. You’ve seen the technology used on Google with Google Maps, on Facebook with real time updates (Without hitting the refresh button) and many other sites.
Before I get into it, if you want to just get to using it, scroll to the HOW TO USE AJAX section below and use it NOW!
WHAT IS IT?
For those who don’t know what Ajax is, IN PLAIN ENGLISH – IF YOU WANT TO UPDATE YOUR WEBSITE INFORMATION WITHOUT HITTING THE REFRESH BUTTON ON THE WEB BROWSER, YOU USE AJAX!
EXAMPLE SCENARIOS:
1. You have a static html webpage, you want to update some information every 30 seconds, such as how many users are online at any given time. You dont want your users to hit the refresh button every time they want to find this info out. AJAX CAN DO THIS!
2. You want to have images load instantly without having to refresh the browser (Like in Google Maps), AJAX CAN DO THIS TOO!
3. You want to have a REAL TIME chat without having to have the user load a java applet or wish to create an instant messenger in your browser. AJAX CAN DO THIS ONE AS WELL!
As you can see, AJAX is made specifically to load data without having to hit the refresh button. Its applications are wide and far reaching and can make your users web experience really COOL!
HOW WAS IT FOUND?
Well AJAX isn’t really new, infact its just a FANCY TERM that was given to the technology that is in plain english is A FEW COOL FUNCTIONS IN JAVASCRIPT! Thats right, thats all it really is, so DONT BE SCARED cause its called some fancy name. AJAX Literally stands for Asyncrhonous Javascript and XML. Take the A from Asynchronous, the JA from Javascript and X from XML and you get….AJAX. Long story short, its like 3-4 functions which when used in combination produce the desired effect of loading data without having to refresh.
It actually existed way back in the 90’s but was re-stumbled upon and now is used as part of WEB 2.0 Technology.
Anyways, so now you know WHAT it is, WHERE you use it…you’re probably wondering HOW to use it right?
HOW TO USE AJAX
1. COPY THE FOLLOWING CODE INTO THE HEAD SECTION OF YOUR HTML FILE
2. Create a div in the body section as follows (It can be any div, but make sure it is assigned an id:
... < body > < div id = "livepage" >< / div > < / body > ...
3. Run the command passing the div id (in this case our div id is called livepage) as well as the page you wish to load into it. For example if you want to load the contact page located at http://www.yoursite.com/contact.html then you would call the command by doing the following anywhere in the body:
Мде …
Какой интересный вопрос…
Замечательно! Спасибо!…
Before I get into it, if you want to […….
В этом что-то есть. Большое спасибо за информацию, теперь я буду знать….
Before I get into it, if you want to […….
В этом что-то есть. Благодарю за информацию….
Before I get into it, if you want to […….