To check whether a request has been made is from Ajax or not you can use $_SERVER[HTTP_X_REQUESTED_WITH]. See the following example:
<?php if(strtolower($_SERVER[HTTP_X_REQUESTED_WITH])==xmlhttprequest){ echo "The request is from an Ajax Call"; }else{ echo "The request is not from an Ajax Call"; } ?>
There you go. You now know how to check whether request made to file is from an Ajax Call or not in PHP.
No comments:
Post a Comment