I work with Django. I have an HTML page where I use some Javascript material and then I make a jQuery message as follows:
$.ajax({ url: '/xenopatients/measurement/qual', type: 'POST', data: {'obj':data}, dataType: 'json', contentType: "application/json; charset=utf-8", //questo ok });
After this mail request, my Django view correctly handles the call for this URL. I want him to process the data, send the user to another page and send this data to a new page. The problem is that I cannot perform the redirection, as usual, in Python, as the code ignores the redirection.
My Python code is:
@csrf_protect @login_required
The only way I found changing the page is through Javascript after the code above:
top.location.href = "/xenopatients/measurement";
But I do not know how to transfer the data that I need when using this method.
HTML code:
<form action="" method=""> <table id="dataTable" width="100%" border="1"></table><br> <script language="javascript"> document.measureForm.id_barcode.focus(); document.measureForm.Add.disabled = false; $('#dataTable').tablePagination({}); </script> <input type="button" name="save" value="Save Measure Serie" onclick="table2JSON('dataTable')"/> </form>
PS I also tried $.post , but with the same results.
How can I do a redirect after a mail request made using jQuery in Django?
source share