[Javascript] Ajax question

billy reisinger billy.reisinger at gmail.com
Mon Jan 1 12:43:10 CST 2007


Someone may have already mentioned this, but I believe the ajax
request object has an "oncomplete" handler in every browser
implementation.  You could always send the ajax request and then set
the window.location to whatever value when the ajax oncomplete event
fires.  That way you can be sure that whatever action was supposed to
happen via ajax actually completes before you change pages.  Something
like this?

requestObj.onComplete = function() {
    window.location = "http://somewhere";
}
requestObj.send();

I dunno, maybe I'm not understanding your problem exactly.
Billy


On 12/31/06, tedd <tedd at sperling.com> wrote:
> At 6:04 PM -0500 12/30/06, Mike Dougherty wrote:
> >On Sat, 30 Dec 2006 15:27:56 -0500
> >  tedd <tedd at sperling.com> wrote:
> >>I know this is hard to understand, but just simply consider this --
> >>if the user clicks (The CLICK) this anchor --
> >>
> >><a href="javascript:sndReq('rock');" >Rock </a>
> >>
> >>-- everything works. Now, how do I redirect the browser to another
> >>page from the same user click (The CLICK)?
> >
> >I don't understand why you think you need ajax.  If the page does a
> >post submission back to the old-school server-side form handler, you
> >can set whatever session variables you want then refresh the page.
>
> I need server-side to know what client-side is doing in real time
> when the user clicks next page.
>
> >Now if the idea is that you have a really archaic FrontPage-style website ...
>
> No.
>
> >So now I wonder what you do with <a
> >href="javascript:sndReq('rock');">Rock</a> if there is no javascript
> >available?  What about doing this:
> >
> ><a href="a_valid_URL_to_go_to.php?what=rock" onclick="return
> >sndReq('rock');">Rock</a>
>
> There's no accessibility problem without js in my current
> investigation. What I'm doing is rather trivial and not necessary for
> the basic operation. It's progressive enhancement, not really needed.
>
> >
> >If sndReq() returns false, the href will not be followed by the
> >click - perhaps it could do
> >window.location=pagerefresh_whatever.html - or it could simply
> >return true and allow the normal function of the <a> tag to work.
> >Arguably better would be:
> >
> ><a id='Rock' href="a_valid_URL_to_go_to.php?what=rock" >Rock</a>
> >
> >...then use some form of unobtrusive javascript to register the
> >click event on the "Rock" object to the sndReq() function given an
> >argument of "Rock"
> >
> >since you have a completely unusuable link given the
> >href="javascript:whatever()" notation, it seems  that this use-case
> >is not what I described above, so if you have control of the page(s)
> >why not eliminate ajax completely?  Given that you want a page
> >refresh after each change of state, you might as well use well
> >proven technologies the way they were meant to be used.
>
> What fun is there in that?
>
> When current technology doesn't fill the bill or is illusive, then
> you must look deeper.
>
> Cheers,
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>



More information about the Javascript mailing list