Welcome Guest, Not a member yet? Register   Sign In
is_ajax_request does not recognized XMLHttpRequest
#2

(This post was last modified: 10-04-2018, 10:04 AM by InsiteFX. Edit Reason: add lines )

Not sure what JavaScript  or framework your using some do not send the HTTP_X_REQUESTED_WITH header. jQuery doe's send it.


You can try this and see what you get this is the old way that we use to do it.


Code:
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

if(IS_AJAX) {
   ... it's an AJAX request so do something ...
}
else {
   ... it's not an AJAX request so do something else ...
}

You can place the define in your ./application/config/constants.php file or were you want.

You may need to send the header yourself.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: is_ajax_request does not recognized XMLHttpRequest - by InsiteFX - 10-04-2018, 10:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB