I would like to determine whether or not a request to my REST API has been made from the jQuery $.ajax()
method.
Before answering this question with one of the obvious answers of adding a boolean to the data sent to the server, or by adding a header, I do not want to do this...
Obviously this can be achieved like so:
$.ajax({
data: {
sentViaAjax: 'true'
}
});
However, for various reasons I would like the boolean/additional header to remain hidden from the code.
Therefore, what I would like to know is does jQuery send any other data in any particular form to the server when it makes a request?
I have tried printing out the $_REQUEST
array but this does not contain anything other than my data sent. Are there any unique headers to look out for? If so, are they reliable, as in, will they always be there?