I want to know how can i make my request work with ajax in my views, while i want to redirect user to other page. I mean for example, when user sends his/her email successfully and I want to redirect him/her to other page. What should I do to make this request work with ajax?
I have this function in views.py:
def compose(request, recipient=None, success_url=None, recipient_filter=None):
if request.is_ajax():
if request.method == "POST":
sender = request.user
form = compose_form(request.POST, recipient_filter=recipient_filter)
if form.is_valid():
// do some processing
if success_url is None:
success_url = reverse('messages_inbox')
if request.GET.has_key('next'):
success_url = request.GET['next']
return HttpResponseRedirect(success_url)
else: //rest of function
And I check in, for example 'messages_inbox', the request to be passed with ajax. so what's the way?