开发者

$_SERVER['HTTP_X_REQUESTED_WITH'] seemingly not available on PHP 5.1.6

I've run into a problem on a server running php 5.1.6 - the code i use to detect ajax requests isn't working as the $_SERVER['HTTP_X_REQUESTED_WITH'] variable is missing from the $_SERVER array. The same code works fine on php 5.2 and in firebug i can see the headers include X-Requested-With XMLHttpRequest. Anyone know any more about this issue and how I can get round it? Thanks in 开发者_如何转开发advance.


Since php is installed as an apache module you can use apache_request_headers() for debugging purposes.
Does the header show up in debuglog.txt when you add

function dbgLogRequest() {
  $s = date('Y-m-d H:i:s') . "\n request headers";
  foreach( apache_request_headers() as $name=>$value ) {
    $s .= "\n  $name: $value";
  }
  $s .= "\n____\n\n";

  file_put_contents('debuglog.txt', $s, FILE_APPEND);
}

dbgLogRequest();

to your code?


The only things I can dig up are:

  • IE browser may not be sending the header
  • If you have a redirect then the header does not get forwarded
  • Inline frames for file uploading don't use ajax so don't send this header

Thats all... Not much else out there...


You are having some kind of a redirect either in your files or in your .htaccess that clears this header.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜