Reputation:
For example if I do this request with jQuery's Ajax:
$(document).ready(function() {
$('#some_button').click(function() {
$.ajax({
url: '/some/request',
type: 'POST',
data: [{my: 'dummy', data: 'lata'}],
dataType: 'json',
async: true,
});
window.location.href = '/my/parent/location';
});
});
So I'm interested:
Will my action be completed on the server nevermind if I'm refreshing the page just right after the initial request is sent?
Upvotes: 1
Views: 133
Reputation: 55740
Ajax is synchronous.. So it will be immediately redirected irrespective of the Request..
You can call that in the success callback of your Ajax Request
instead..
$(document).ready(function() {
$('#some_button').click(function() {
$.ajax({
url: '/some/request',
type: 'POST',
data: {my: 'dummy', data: 'lata'},
dataType: 'json',
success : function() {
window.location.href = '/my/parent/location';
}
});
});
});
Upvotes: 1