I am using this php function which checks if the request is an Ajax
request or not which works fine.
function ajax_check() {
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
return TRUE;
} else {
return FALSE;
}
}
I want to know the dataType
of the Ajax
request. For example if the dataType
is json
or not. How can i achieve this using php?
You can check it in request headers
Accept application/json, text/javascript, /; q=0.01
there will be "text/html" or application/json