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 ?
JavaScript
x
25
25
1
$('#form_edit').submit(function (e)
2
{
3
e.preventDefault();
4
$.ajax({
5
url: $('#form_edit').attr('action'),
6
type: 'POST',
7
cache: false,
8
data: $(this).serialize(),
9
success: function (data) {
10
if (data === true) {
11
alert("Modification réussie !");
12
window.history.back();
13
location.reload(); <= on success i want to refresh previous page
14
}
15
else {
16
alert("Modification échouée !");
17
}
18
},
19
error: function ()
20
{
21
alert("Modification échouée !");
22
}
23
})
24
})
25
Advertisement
Answer
It will have already gone back before it executes the reload.
You would be better off to replace:
JavaScript
1
3
1
window.history.back();
2
location.reload();
3
with:
JavaScript
1
2
1
window.location.replace("pagehere.html");
2