AJAX - The Complete Reference

(avery) #1

Chapter 2: Pre-Ajax JavaScript Communications Techniques 31


PART I


A complete simple cookie-based transmission example can be found at http://ajaxref
.com/ch2/onewaycookie.html and is shown running in Figure 2-4.
You might think that we would have to change setrating.php to work with cookies, but
because PHP super global array $_REQUEST[] is used it ports directly. However, you
should be quite careful with cookies since you do not want them hanging around on future
requests. Furthermore the cookie-only transport mechanism is problematic as it suffers from
numerous issues including size limits, user denial of setting cookies, and of course privacy
paranoid user purging.
Having seen this rating example a good half-dozen plus times, you are probably
thinking that you are bored with it. Practically speaking, while the example is good to show
the pattern in a simple fashion, it is clearly a bit misleading because you aren’t receiving any
real indication that your vote was counted. With two-way requests, any concern of voter
fraud will be rectified by displaying a confirmation of the vote, indication of the number of
votes cast, and the average. However, one-way requests are not just academic. Later in the

FIGURE 2-4 Cookie transport up close
Free download pdf