Accelerated DOM Scripting with Ajax, APIs, and Libraries by Dan Webb & Stuart Langridge & Aaron Gustafson & Jonathan Snook
Author:Dan Webb & Stuart Langridge & Aaron Gustafson & Jonathan Snook [Dan Webb]
Language: eng
Format: epub
Tags: Design, Digital Media, JavaScript, Web Development
Publisher: Apress
Published: 2007-09-25T21:00:00+00:00
if(transport)
{
transport.open("GET", "http://example.com/test/", true);
transport.onreadystatechange = function(){ alert('I am back!'); };
transport.send();
} This is the basic structure of an Ajax request. The first part instantiates the XHR object, beginning with trying to instantiate a native version of the object. If a native implementation is not found, it attempts to instantiate the ActiveX objects for Internet Explorer (IE). (You'll learn more about why we check for both implementations later on.)
The second part takes the object and opens a connection with three parameters: the first specifies the method (GET or POST), the second is the URL you want to open, and the third determines whether the call should be synchronous or asynchronous.
If the third parameter is set to synchronous (false), the browser will wait for the call to return before users can do anything. This isn't ideal because users might think their browser has frozen and needs to be shut down. Setting it to true makes the call asynchronous, enabling the user to return to interact with the page while the call processes in the background.
The status of the XHR request makes a number of calls to the onreadystatechange event handler. From within the event handler, you can check the status of the call by checking the readyState property on the XHR object: transport. The readyState property will store a number between 0 and 4 at any given time (see Table 5-1).
Table 5-1 Possible readyState States Value State Description
0 Uninitialized The open method of the XHR object hasn't been called yet.
1 Loading The send method hasn't been called yet.
2 Loaded The send method has been called; response headers are available.
3 Interactive The response data is in the process of downloading, and is available via the responseText property of the XHR object.
4 Completed Everything is done, and the entire result is available in the responseText and, if available, the responseXML properties of the XHR object.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12569)
Hello! Python by Anthony Briggs(9914)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8296)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7064)
Microservices with Go by Alexander Shuiskov(6825)
Practical Design Patterns for Java Developers by Miroslav Wengner(6746)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6688)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Angular Projects - Third Edition by Aristeidis Bampakos(6092)
The Art of Crafting User Stories by The Art of Crafting User Stories(5617)
NetSuite for Consultants - Second Edition by Peter Ries(5556)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5360)
Kotlin in Action by Dmitry Jemerov(5062)
