[Javascript] Ajax question

Matt Warden mwarden at gmail.com
Mon Jan 1 13:15:46 CST 2007


Yes, the problem is likely that the sendreq function is executing in
an asynchronous manner. The window.location line redirects before the
request gets sent to the server.

I would suggest using javascript to queue up location changes if there
is a pending ajax request, then using the onreadystatechange event
handler to execute any pending location change when readystate is 2 or
higher. This should be sufficient, but theoretically you could still
run into the case where your server side app layer has not set the
session variable yet, but it is already processing the second request
(location change). You can't avoid this case; you can ony impose
enough of a delay to make it unlikely.

You make this solution accessible by allowing links to work in the
usual fashion if js is not available. Someone else in this thread
explained how to accomplish this.

Hope this helps,

--
Matt Warden
http://matttwarden.com
Cleveland, OH, USA



-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the Javascript mailing list