Thanks for the pointers! I finally got it to work. I had been doing similar to your suggestion (returning ajax response like ["redirect_to": "http://www.example.com"], but I had been having issues with setting the location and wasn't sure if that was the right thing to be doing. For some reason when I had a url that had a / before an anchor, ie http://www.example.com/#comment_32, it wasn't redirecting correctly and that was throwing me off. Maybe that's not even legal and just happens to work when I type it in. Anyway, once I got rid of the '/' before the anchor (www.example.com#comment_32) and used
document.location = url that did the trick. Thanks very much for your comments, that was a big help. Margie On Sep 15, 6:41 am, Alex Robbins <alexander.j.robb...@gmail.com> wrote: > Making the browser switch pages isn't too bad. Just set > document.location to the new url using javascript. (The document > object should be provided by the browser.) > Maybe you should check the headers of the ajax response and if it is a > redirect make the redirect happen using javascript? Or simply make one > of the ajax responses be {"redirect_to": "http://www.example.com/"} > and parse it out on the client side. > > Hope that helps, > Alex > > On Sep 15, 2:07 am, Margie Roginski <margierogin...@yahoo.com> wrote: > > > I have a situation where the user fills in a form and hits submit to > > post the form. If my views.py code detects an error in the form, I > > want to return some info to the client and put it into the dom via > > jquery. If there is no error, I want to redirect to another page. > > Can anyone advise me on the best way to do this? I've succesfully > > used $.post() to grab the error info and put it in the dom. However, > > in the case where there is no error, I can't figure out how to do the > > redirect. > > > I've tried having the views.py code pass back the url that I want to > > redirect to, and then when my $.post() callback function is called, it > > sets window.location to that url. But this seems to have some issues > > when the url contains an anchor (for some reason firefox seems to > > cache anchored urls and not redirect to them in the normal way). > > > Is there any way to specify that even though $.post() started the > > server request, that the server should just redirect to a url (ie, > > using just the basic HttpResponseRedirect() or something like that) > > and not return and call the $.post callback function? > > > Thanks for any pointers, > > > Margie > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---