• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is_ajax_request() doesn't work from mobile apps

#1
I'm not sure if this is expected or if there's an alternative, but is_ajax_request() doesn't work from when handling an ajax request from a mobile app.

I'm developing an app using Phonegap, with my existing CI3 site as the back end. I have several methods setup to return data as JSON (these are also used in the normal web-based version of the app). I prevent direct access to these using an is_ajax_request() check, but this is failing when called from my mobile app (returns false).

Anyone know if there is a workaround or fix for this?

Thanks
Reply

#2
is_ajax_request() depends on a non-standard HTTP request header named 'X-Requested-With', that for AJAX requests should have the value of 'XMLHTTPRequest' (case-insensitive). It is the client that sends or doesn't sent that header, and as far as any server is concerned - an HTTP request is an HTTP request, it doesn't know who, what or how has sent it.

If the client (in your case, the mobile device) doesn't say that it is sending an AJAX request, the server has no way of knowing that. Therefore, if anything can be "fixed" it's the client.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.