[Javascript] Ajax question

Stephan Wehner stephanwehner at gmail.com
Sat Dec 30 13:41:21 CST 2006


On 12/30/06, tedd <tedd at sperling.com> wrote:
> At 10:54 AM -0800 12/30/06, Stephan Wehner wrote:
> >>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".
>
> Sorry for my vagueness. The "doesn't work" remark simply means that
> the page doesn't refresh.
>
> The 'rock' variable is sent to, and received, by the ajax routine.

> >I think you should put the location.href assignment  in the asynchronous
> >part of the AJAX request -- onComplete: in prototype.js.
>


See

http://www.sergiopereira.com/articles/prototype.js.html#UsingAjaxRequest


> [1] How?
>
>
> >(I don't know what sndReq is). Are you seeing the sndReq - rock ; or
> >are you not seeing the location.rhref='...' ?
>
> The "sndReq(action)" is the typical sndReq() function associated with ajax.
>
> -snip- back button considerations
>
> You lost me there.


I'll keep on your topic now. I thought you were trying to do something
related, but it doesn't look like that anymore.



>
> >What was your motivation?
>
> The purpose of my investigation is to pass a variable between pages
> using php sessions and ajax.

> I have no problems passing variables between pages using php
> sessions. I also have no problems using ajax to pass a variable to a
> php session. However, I can't get a ajax operation to pass a variable
> and refresh/redirect the browser to another page in one click.

I don't quite understand; but what is the difference to using URL's like

<a href="http://yourserver.net/thepage?param1=value1&param2=value2">

The params and values can be computed with javascript ( < a href="#"
onClick="location.href= computeURLwithParams();">link</a> ) where
computeURLwithParams() is a javascript function that returns a string
like

http://yourserver.net/thepage?param1=value1&param2=value2.

based on whatever you are trying to do.

I'm getting the impression you are trying to pass values to the server
in one request so that the response to the next request can take those
values into consideration. Can you not pass the values all in one go?

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