I have the following situation. I need to fire some event right after my ajax request was sent but before it has completed. Looking at the documentation I see whole bunch of events: beforeSend
, complete
, error
, success
, done
, always
. But there is nothing that looks like event I want.
So is it possible to do?
Just to highlight what exactly do I want to achieve:
var foo = 'BAR';
$.post('serverURL', {
T: foo,
}, function(data){
//...
}, 'json');
foo = '';
So I have a code similar to this. And the way it works is perfectly fine (it sends correct foo
to the server and than right after it send it it modifies it). It modifies it not when the ajax is done/finished/successed/failed, but right after it fires.
I want to put this modification foo = ''
in a callback, (like success callback). Just to answer why do I need to do this: some people when they read a code, decide to "improve" it by moving foo = ''
somewhere else (before the ajax) and thus introduce the bug which is hard to spot. Comments like // Do not move it do not help.