then the beforeSend hook is called correctly. Console output will be
SETUP
BEFORE SEND
MOCKJAX
However you can't get the request headers this way. According to this section of the docs: https://github.com/jakerella/jquery-mockjax#accessing-request-headers to get to the headers you have to pass a function to mockjax, and the docs even state that you could check headers that would be added by beforeSend, however beforeSend is not called when configured this way.
It looks like beforeSend is called, but out of order. If the mockjax function returns successfully, then beforeSend appears to be called after the mockjax handler...
It seems that if you setup a project like:
then the
beforeSend
hook is called correctly. Console output will beHowever you can't get the request headers this way. According to this section of the docs: https://github.com/jakerella/jquery-mockjax#accessing-request-headers to get to the headers you have to pass a function to
mockjax
, and the docs even state that you could check headers that would be added bybeforeSend
, howeverbeforeSend
is not called when configured this way.console output is just
CORRECTION:
It looks like
beforeSend
is called, but out of order. If the mockjax function returns successfully, thenbeforeSend
appears to be called after the mockjax handler...Example code: https://codesandbox.io/s/blissful-glade-l13m8
This seems to contradict the documentation.