|
| You are here: Categories » Computers and technology » AJAX and JavaScript
|
There are a number of cases in which you might not have XMLHttpRequest support. The most common would be in the case of an older browser. This is the hardest to work around, not because there is no AJAX fallback, but because all the other DOM manipulation that you do within the application won't work. Another problem case is when your browser supports everything that is needed except for XMLHttpRequest. This problem could occur when IE is in a mode where it can't use ActiveXObjects or when you are using a pre-7.6 version of Opera.
In some cases, especially intranet applications, it's easy to just require an upgrade, but if you want to use AJAX on a public site, you'll want to think about using some sort of fallback mechanism. The best candidate for a fallback is to use hidden IFrames. Another option is to use cookies, but they can send only a limited amount of data per request, so it is hard to drop in cookie-based approaches as a replacement for code that has been written with XMLHttpRequest in mind. Only XMLHttpRequest supports synchronous calls, so if they are necessary for your application, then using it as a fallback will not be possible.
Advantages and Disadvantages of AJAX Techniques
| Technique |
Advantages |
Disadvantages |
| XMLHttpRequest |
Can make requests to pages not set up for AJAX
Can set/get all HTTP headers
Can make HTTP requests using any type (GET, POST, PROPFIND, and so on)
Supports full control over POST requests, allowing for any type of data encoding |
Requests ActiveX to be enabled in IE 5 and 6
Is only available in newer versions of Opera and Safari
Has small implementation differences between browsers |
| IFrame |
Can make POST and GET HTTP requests
Supportes all modern browsers
Supports asynchronous file uploads |
Prohibits synchronous requests
Server pages must be designed to work with IFrame requests
Has implementation differences between browsers
Can leave extra entries in browser history (depends on browser and implementation)
All request data is URL-encoded, increasing request size |
| Cookies |
Supports the largest number of browsers
Few implementation differences between browsers |
Prohibits no synchronous requests
Doesn't work with large requests/results
Requires server pages to be designed to work with cookie requests
Requires polling on the client Can make only GET HTTP requests |
If you're using a fully wrapped XMLHttpRequest and you don't use synchronous calls, providing transparent fallback to your program should be possible. You need only to replace the final throwing of an exception in the example init method with the instantiation of your IFrame HTTP client. The main item to remember about using another approach instead of XMLHttpRequest is that it's not going to gain you huge leaps in compatibility.
The major browsers already support XMLHttpRequest. This support makes browsers with JavaScript turned off, not those running an unsupported browser, the biggest group that can't use your AJAX application. |
|
Leave a comment or ask a question
|
|
Total comments: 0
Disclaimer
- The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
|
|
|
JavaScript Variables - I like to think of variables as containers on a container ship. You can put all different types of content into the containers, move them to another port, empty them, and then replace the contain (more...)
JavaScript Operators - Operators can be placed into three categories-binary, unary, and ternary. Binary operators, most commonly associated with the concept of operator, take two (binary) expressions and combine them in (more...)
JavaScript Arrays - Because objects are collections of properties with each property having its own name and value, arrays are actually JavaScript objects. Each property in an array is an element, and each element (more...)
Loops in JavaScript - Loops in JavaScript are similar to loops in C++ and Java and most other languages using loop structures. In this section, you will find explanations of the different types of loops in JavaScript (more...)
Types of operators in JavaScript - Assignment Operators
The key assignment operator is the equals sign (=). The left operand is a variable, an array element, or an object property, and the righ (more...)
Conditional Structures - The "thinking" structure in JavaScript is found in the different types of conditional statements in the language. Used in concert with different types of comparative operators, conditional statem (more...)
The ''with'' Statement - Like the ternary conditional operator, the with statement is a shortcut. Instead of having to list all of the properties of an object by repeating the basic object, you can state the bulk (more...)
Operators Precedence - The order in which expressions are evaluated based on their operators is known as precedence. Multiplication and division occur before addition and subtraction, so any operands that are to be mul (more...)
AJAX Usability Guidelines - Many usability experts have criticized AJAX by pointing out cases where it hurts usability. Although it is possible for AJAX to have that effect, I don't think AJAX inherently hurts usability; (more...)
|
|
|