AJAX - The Complete Reference

(avery) #1

PART II


Chapter 9: Site and Application Architecture with Ajax 427


<title>Voting Results for downgraded version</title>
</head>
<body>
<h3>If you are not using JavaScript, you will see this downgraded page with
results</h3>
<?php echo $message ?>
</body>
</html>

Now with this in place, we have an even more robust rating facility, as shown in
Figure 9-4, which works under three different conditions: no script, script but no Ajax,
and full capabilities. Verify yourself by visiting the example at http://ajaxref.com/ch9/
ratingprogressive.html.

NNOT EOTE To disable XHR transport in Internet Explorer, first go to Internet Options and disable
XMLHttpRequest via the Advanced tab, and then turn off ActiveX controls via the Security
tab. To disable XHR transport in Firefox, first type about:config in the address bar. Next,
right-click and create a new string. Name the property capability.policy.default
.XMLHttpRequest.open and set the value to be “noAccess.” You now should find that
XHRs are denied. Of course, if you want to turn it back on, you need to set the property to a
value of “sameOrigin.” There is a very interesting value of “allAccess” as well, but don’t
set that unless you know what you are doing.

There is some great news in what we did here: it keeps the application accessible. Since
our example works without JavaScript, we can certainly meet accessibility guidelines!

Degrading Not Enhancing


The previous example is very robust, but you may find that you dislike the extra work
necessary to support non-JavaScript-aware browsers, or simply feel that without advanced
JavaScript-powered functionality, the application just doesn’t make sense. You certainly

FIGURE 9-4 Really robust ratings
Free download pdf