In my case, I will send a 302, and set the response text to the url
for login.  Then, in javascript if the response is a 302 I can just
generically redirect.

For example, in the controller:

render :text => login_url, :status => 302

In the view, I add a failure directive into the link_to_remove like so:

:failure => 'processFailure(request)'

Here is the processFailure javascript method I use:

function processFailure(request) {
  if (request.status == 302) {
        window.location = request.responseText;
  } else {
        alert('An error has occurred: ' + request.responseText);
  }
}

Tom

On 2/21/06, Jeremy Kitchen <[EMAIL PROTECTED]> wrote:
> On Tuesday 21 February 2006 14:36, Grzesiek Slusarek wrote:
> > Hello All. I'm making ajax call to some url but to connect and
> > get data from that url first I check session for user which using
> > AJAX. If session is expired I redirect Ajax call to other url.
> > That url return form to login. There is one problem - I check in
> > function onResponse(OriginalRequest) OriginalRequest status and
> > status is always 200 - whatever I'm logged or not. So i can't
> > identify from what url i'm getting data. Can someone tell me what
> > I'm doing wrong?
>
> return a different status than 200 instead.
>
> I believe a 403 would be appropriate here, however, HTTP status codes are a
> bit confusing to me, so if someone has a better one to use, please speak
> up :)
>
> -Jeremy
>
> --
> Jeremy Kitchen ++ [EMAIL PROTECTED]
>
> In the beginning was The Word and The Word was Content-type: text/plain
>   -- The Word of Bob.
>
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
>
>
>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to