1๐
โ
If I understand correctly, after the contact form is submitted you want a modal to appear saying thanks.
Instead of:
return HttpResponseRedirect('/thanks/')
Do:
import json
...
return HttpResponse(json.dumps({"success":True}), content_type="application/json")
And in your JS that submits the form check the response for success before reloading the HTML form:
if (typeof jqXhr.success != 'undefined') {
$('#success-modal').modal('show');
} else {
$('#my-form').html(jqXhr);
}
๐คdotcomly
Source:stackexchange.com