POST content in the web page to the background and POST jump to other sites (homologous and cross-domain at the same time)!

The

site is written in DJANGO, and the page already has a FORM to submit to the background.
but I want him to jump to other sites at the same time when he submits, and need POST data at the same time when he is redirected.
and my FORM form is validated with DJANGo.from when it is submitted to the background, so how can I jump when the verification is passed?
how can I implement this need with javascript? GOOGLE can"t find a clue for several days, either it"s the same origin problem, or it"s the problem of redirecting unable to POST the data.


return 301 or 302 to let the browser jump


there is a success_url in the django forms form, which means URL, redirected after successful form validation. Your requirements are usually addressed here.

you can read the official form form in more detail, whether it's a function-based view or a class-based view, it's easier for you to solve this requirement.

official example:

from django.http import HttpResponseRedirect
from django.shortcuts import render

from .forms import NameForm

def get_name(request):
    -sharp if this is a POST request we need to process the form data
    if request.method == 'POST':
        -sharp create a form instance and populate it with data from the request:
        form = NameForm(request.POST)
        -sharp check whether it's valid:
        if form.is_valid():
            -sharp process the data in form.cleaned_data as required
            -sharp ...
            -sharp redirect to a new URL:
            return HttpResponseRedirect('/thanks/') -sharp 

    -sharp if a GET (or any other method) we'll create a blank form
    else:
        form = NameForm()

    return render(request, 'name.html', {'form': form})
Menu