Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 72899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:07:01+00:00 2026-05-10T20:07:01+00:00

I have written a web app in PHP which makes use of Ajax requests

  • 0

I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest).

Most of the time, this works fine. The request is sent with an X-Requested-With value of XMLHttpRequest. My PHP controller code uses apache_request_headers() to check whether an incoming request is Ajax or not and all works well.

But not always. Intermittently, I’m getting a situation where the Ajax request is sent (and Firebug confirms for me that the headers on the request include an X-Requested-With of XMLHttpRequest) but apache_request_headers() is not returning that header in its list.

The output from when I var_dump the apache_request_headers() is as follows (note the lack of X-

'Host' => string 'peterh.labs.example.com' (length=26) 'User-Agent' => string 'Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3' (length=105) 'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63) 'Accept-Language' => string 'en-gb,en;q=0.5' (length=14) 'Accept-Encoding' => string 'gzip,deflate' (length=12) 'Accept-Charset' => string 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' (length=30) 'Keep-Alive' => string '300' (length=3) 'Connection' => string 'keep-alive' (length=10) 'Referer' => string 'http://peterh.labs.example.com/qmail/' (length=40) 'Cookie' => string 'WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6' (length=57) 'Pragma' => string 'no-cache' (length=8) 'Cache-Control' => string 'no-cache' (length=8) 

But Firebug tells me:

Request Headers: Host             peterh.labs.example.com User-Agent       Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3 Accept           text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8 Accept-Language  en-gb,en;q=0.5 Accept-Encoding  gzip,deflate Accept-Charset   ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive       300 Connection       keep-alive X-Requested-With XMLHttpRequest Referer          http://peterh.labs.example.com/qmail/ Cookie           WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6 

This mismatch is (apparently) intermittent when executing the same code. But I don’t believe in ‘intermittent’ when it comes to software! Help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:07:02+00:00Added an answer on May 10, 2026 at 8:07 pm

    I’m not sure why the apache_request_headers() and firebug mismatching, but in order to read request headers you can use the $_SERVER super global

    each header that is being sent by a client (and it doesn’t matter how is the client) will arrive to the $SERVER array. The key of that header will be with HTTP prefix, all letters capital and dash is converted to underscore (_)

    in your case you can find your necessary value in:

    $_SERVER[‘HTTP_X_REQUESTED_WITH’] = ‘XMLHttpRequest’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application solution which is made up of a web app written
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321
I have a web application, written in ColdFusion, which periodically starts using 100% of
Say I have a mobile web app written using JQuery Mobile, this app retrieves
I have an asp.net web page written in C#. Using some javascript I popup
I have a completed web app in PHP 5 + MySQL. I have not
I have a web application written in PHP. It uses MySQL for data storage.
In my web app, I have some complex objects written with JavaScript (ie nested
I have a webapp written in PHP using a MySQL database backend. This question
I have written a web app that requires IE version 8 (or higher presumably).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.