I’ve a probleme in my code. The aim is to complete a simple form, then you click on a submit button. It do an Ajax resquest to go in the method. On success in the ajax request, i use windows.history.back() to go to the previous page ans here i want to refresh this page, to refresh values which are modificated by the form ! Have you an idea about that ?
$('#form_edit').submit(function (e) { e.preventDefault(); $.ajax({ url: $('#form_edit').attr('action'), type: 'POST', cache: false, data: $(this).serialize(), success: function (data) { if (data === true) { alert("Modification réussie !"); window.history.back(); location.reload(); <= on success i want to refresh previous page } else { alert("Modification échouée !"); } }, error: function () { alert("Modification échouée !"); } }) })
Advertisement
Answer
It will have already gone back before it executes the reload.
You would be better off to replace:
window.history.back(); location.reload();
with:
window.location.replace("pagehere.html");