SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 175 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

XMLHTTP, now map directly to
version 3.0 (even if version 6.0 is installed). This really only leaves you with two possible
program IDs (referred to as progIDs by Microsoft):
??? Msxml2.XMLHTTP
??? Msxml2.XMLHTTP.6.0
Version 6 was introduced in IE 7 and includes some bug fixes (such as the one mentioned
earlier, in which IE 5 and 6 fail when the onreadystatechange is declared before the
open call). Although IE 7 includes a native XHR object, users have the option of disabling it.
Therefore, it??™s a good idea to test for Msxml2.XMLHTTP.6.0 first; if it doesn??™t work, fall back to
the other version.
Planning for Failure
Now that you have the basic Ajax object in place, let??™s review possible problems and work to
build solutions to those problems into the object:
??? What happens if the request times out? How long should you wait?
??? What happens when the data you get back isn??™t what was expected?
??? What happens when multiple requests are made? (Especially if they come back in a different
order from what was requested!)
CHAPTER 5 n AJAX AND DATA EXCHANGE 119
Handling Timeouts
Ajax calls usually stay open for as long as the server keeps the connection open. However, if
you have an unresponsive server, it might be too long for the user to wait. A more ideal solution
is to simply time out the call and handle the error. I made the necessary updates to the
Ajax object, which I highlighted in bold:
function Ajax()
{
var transport;
if(window.


Pages:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6