
JavaScript Summary This tutorial has taught you how to add JavaScript to your HTML pages, to make your web site more dynamic and interactive. You have learned how to create responses to events, validate forms and how to make different scripts run in response to different scenarios. You have also learned how to create and [...]
Read More >>

W3Schools offers an Online Certification Program. The perfect solution for busy professionals who need to balance work, family, and career building. More than 6000 certificates already issued! Document Your Skills Knowledge is power, especially in the current job market. Documentation of your skills enables you to advance your career, or help you to start [...]
Read More >>

AJAX can be used for interactive communication with a database. AJAX Database Example The following example will demonstrate how a web page can fetch information from a database with AJAX: Example Select a customer: Alfreds Futterkiste North/South Wolski Zajazd Customer info will be listed here… Try it yourself » Example Explained – The showCustomer() Function [...]
Read More >>

AJAX can be used for interactive communication with an XML file. AJAX XML Example The following example will demonstrate how a web page can fetch information from an XML file with AJAX: Example Get CD info Try it yourself » Example Explained – The stateChange() Function When a user clicks on the “Get CD info” [...]
Read More >>

AJAX is used to create more interactive applications. AJAX ASP/PHP Example The following example will demonstrate how a web page can communicate with a web server while a user type characters in an input field: Example Start typing a name in the input field below: First name: Suggestions: Try it yourself » Example Explained – The [...]
Read More >>

When a request to a server is sent, we want to perform some actions based on the response. The onreadystatechange event is triggered every time the readyState changes. The readyState property holds the status of the XMLHttpRequest. Three important properties of the XMLHttpRequest object: Property Description onreadystatechange Stores a function (or the name of a [...]
Read More >>

Server Response To get the response from a server, use the responseText or responseXML property of the XMLHttpRequest object. Property Description responseText get the response data as a string responseXML get the response data as XML data The responseText Property If the response from the server is not XML, use the responseText property. The [...]
Read More >>

The XMLHttpRequest object is used to exchange data with a server. Send a Request To a Server To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object: xmlhttp.open(“GET”,”ajax_info.txt”,true); xmlhttp.send(); Method Description open(method,url,async) Specifies the type of request, the URL, and if the request should be handled asynchronously [...]
Read More >>

The keystone of AJAX is the XMLHttpRequest object. The XMLHttpRequest Object All modern browsers support the XMLHttpRequest object (IE5 and IE6 uses an ActiveXObject). The XMLHttpRequest object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole [...]
Read More >>

To understand how AJAX works, we will create a small AJAX application: Example Let AJAX change this text Change Content Try it yourself » AJAX Example Explained The AJAX application above contains one div section and one button. The div section will be used to display information returned from a server. The button calls a [...]
Read More >>