|
Location: Web development - Ajax & Atlas License: The Intelliproject Open License (IPOL) Using Ajax with Javascript and PHPPosted by Silviu CarageaIn this article we'll discuss the basic principles of remote scripting using Ajax, (asynchronous JavaScript and XML) to allow web pages to be updated without the user having to wait for a page refresh. |
Skill: BeginnerPosted: 18/10/2008Views: 482Rating: 5.00 /5Popularity: 1.51 |
| Sign Up to vote for this article |
In this article we'll discuss the basic principles of remote scripting using Ajax, (asynchronous JavaScript and XML) to allow web pages to be updated without the user having to wait for a page refresh.
Wait server to complete the request.

Display the request response .

Ajax script makes a request of a server by using XMLHTTPRequest object. XMLHttpRequest (XHR) is a DOM API that can be used by JavaScript and other web browser scripting languages to transfer XML and other text data between a web server and a browser.
There are some relatively simple steps to use Ajax in your application.
1. Create an XMLHTTPRequest object .This process differs slightly depending on what you are using: Internet Explorer (5+) with ActiveX, or a standards-compliant browser like Firefox.
request = new ActiveXObject('Msxml2.XMLHTTP');request = new XMLHttpRequest();The following javascript function create your XMLHTTPRequest object for all supported browsers:
2. We need to write an event handler which will be called via some event on your webpage, and will handle sending our request for data to our server.
We can make our request of the server by using a GET method to an appropriate server-side script.
Note that the function listens to the onreadystatechange property of the XMLHTTPRequest object and, each time this parameter changes, calls a further anonymous function.
These functions establish when the server has completed our request, and do something useful with the data it has returned. In this case, we have received our information as simple html text via the responseText property.
This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)
| Silviu Caragea
| Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject. He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy. His programming experience includes: - C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL) - Open Source libraries :CURL & Boost - HTML, CSS - Java (SE,ME) - JavaScript, Ajax, Google Web Toolkit (GWT) - Php, MySQL -Oracle, PL SQL - C# .NET -Objective C, IPhone SDK, Cocoa Location: |
Sign up to post message on the article message board!