I have a simple ajax request:
$.post('server.php',data, function (json) {console.log(json)},'json');
I've set it up so that jQuery is expecting json as specified by the last dataType
setting.
Related question: Is dataType
another name for responseType
? See http://msdn.microsoft.com/en-us/library/windows/apps/hh871381.aspx
Now my real question. server.php sometimes returns json, other times html, and other times xml, and will set the appropriate header when rendering the response.
Before rendering the response, however, the server needs to determine what type of data to provide. I wish to base the response upon the dataType
and/or responseType
header it receives from the client. How do I read this header within PHP?