1

I have a PHP script which is displaying a drop-down box.Now when I select a drop down box an ajax call is made to the PHP script , which works fine , I can see in firebug that the call has been made and correct parameter is passed.I am using this code in php to identify if the call has been made

isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 
       ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')

But this check always fails and I do not get any response.How can I debug this?

1
  • And what value is actually in $_SERVER['HTTP_X_REQUESTED_WITH']? Commented Dec 16, 2010 at 4:40

1 Answer 1

2

did you check in firebug -net tab - if the header HTTP_X_REQUESTED_WITH is being sent?

Sign up to request clarification or add additional context in comments.

4 Comments

@scrum awesome , I do not see it anywhere in header sub tab of the net tab in firebug.I have read that $_SERVER is not a php variable but is generated by the web server , so if it generated by webserver then how can we control it?
$_SERVER is a php variable that gets populated by the server. what are you using to sent the AJAX call?
@scrum I am using this code , i am not sure if i should set the header or not.xmlhttp.open("GET","index.php?name="+name,true); //xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xmlhttp.send();
by default it will not send the header. use xmlhttp.setRequestHeader('X_REQUESTED_WITH','XMLHttpRequest');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.