I'm trying to find a way to reload the page after completing an AJAX
update.
My Basic code is:
updateEdit = function() {
$('#editSection').on('click', '#Changes', function() {
/*set var here*/
$.ajaxSetup({
data: {
var1: 1,
var2: 2
}
})
ajaxUpdate();
});
}
ajaxUpdate = function() {
$.ajax({
type: 'GET',
url: 'update.php',
data: {},
success: function(data) {
alert(data);
centerItem('#savedBox');
},
error: function(jqxhr) {
alert(jqxhr.responseText);
}
})
}
So far so good. I now need to pause for 1 second, then roload the page. Looking around suggests I need to use setTimeout(location.reload, 1000);
so I added in
complete: function() {
setTimeout(location.reload, 1000);
}
to the $.ajaxsetup()
but that seemingly did nothing.
I then added it to the main ajaxUpdate()
function, (not ideal as I don't want it to fire on every ajaxUpdate) whereby I got an Uncaught TypeError: Illegal invocation
error. (and no page reload).
What am I doing wrong?