[Javascript] Ajax question

Stephan Wehner stephanwehner at gmail.com
Sat Dec 30 12:54:53 CST 2006


> The following doesn't work:
>
>   <a onclick="javascript:sndReq('rock');"  href="" >Rock </a>
>

It's not clear to me what you mean by "doesn't work". I think you
should put the location.href assignment  in the asynchronous part of
the AJAX request -- onComplete: in prototype.js.
(I don't know what sndReq is). Are you seeing the sndReq - rock ; or
are you not seeing the location.rhref='...' ?

If I understand you correctly, I was going to look into this as well:
I thought this might be a nice way to get the back button to work,
while still seeing browser performance improvements.

What I was thinking was to change a link to a site internal page
(which is assumed to use the same CSS and javascript) so that the
browser first requests the page through XHR, then replaces a target
<div> with a substring of the response (remove <head> etc), and then
points the whole page with location.href to the same URL.

The response to the second request might be arranged not to send the
whole page again, since the browser already has it.

In total, my hope was that the user sees the resulting page much
faster, while the second request puts the right URL in the browser bar
-> a solution to the Back button/history/bookmarking problem that
comes with AJAX. If no javascript is available on the browser, the end
result is the same: the user lands on the same page.

What was your motivation?

Stephan

-- 
Stephan Wehner
> http://stephan.sugarmotor.org
> http://stephansmap.org
> http://www.trafficlife.com
> http://www.buckmaster.ca



More information about the Javascript mailing list