I’m having some trouble with detecting a jQuery ajax request with PHP on a Lighttpd web server. Here’s the following code (works fine on MAMP and Apache):
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// ajax (not recognized on lighttpd server)
echo json_encode(array('success'=>1));
}
else {
// not ajax
}
I thought perhaps there’s a certain lighttpd config that’s not set correctly, but didn’t see anything I recognized. Anyone have any experience with an issue like this?
Thanks!
Perhaps you can have the ajax request append another variable to the query. Then instead of testing for the $_SERVER var, you can simply test for the ajax only $_REQUEST var.
Can you share any of the jQuery code?