473,473 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

why do some HTTP headers show up in $_SERVER? Why not $_GET or $_POST ???


I noticed this odd PHP function in an article about AJAX and Prototype:

http://www.sitepoint.com/article/pai...pt-prototype/2

Prototype adds a custom HTTP header to all its AJAX requests so that your server
application can detect that it's an AJAX call, rather than a normal call. The header is:

X-Requested-With: XMLHttpRequest

Here's an example PHP function used to detect an AJAX call:

function isAjax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
$_SERVER ['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
}

Most of the AJAX calls I've seen are GET or POST, so I expect them to
show up in the $_GET or $_POST arrays. Why would this header show up in
the $_SERVER array?

Apr 7 '06 #1
2 1762

lawrence k wrote:
Most of the AJAX calls I've seen are GET or POST, so I expect them to
show up in the $_GET or $_POST arrays. Why would this header show up in
the $_SERVER array?


A HTTP header is not an extra parameter passed via GET or POST. See
http://www.php.net/manual/en/function.header.php.

Apr 7 '06 #2
lawrence k:
Most of the AJAX calls I've seen are GET or POST, so I expect them to
show up in the $_GET or $_POST arrays. Why would this header show up in
the $_SERVER array?


GET and POST are just the names of two methods of sending an HTTP
request, not to be confused with the PHP variables of the same name.
The PHP variable $_GET makes available name=value pairs passed in the
query part of the request-URL (even if the actual method is POST), and
$_POST makes available name=value pairs passed in the body of the
request. $_SERVER, on the other hand, makes available some but not all
of the headers of the request.

http://www.php.net/manual/en/languag...predefined.php

HTH.

--
Jock

Apr 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Lisa Pearlson | last post by:
Hi, I have a php script with no more than this: <?php echo "Hello World!"; ?> When a webbrowser client requests data, it receives Apache server headers, followed by my data: HTTP/1.1 200...
3
by: Rick Edwards | last post by:
Can I do this? If I'm passing info in my HTTP headers, can I read this info via Javascript? I've seen some hope out there, but nothing definitive - I'm hoping to get that answer here.... TIA...
2
by: Jane Withnolastname | last post by:
I have seen many posts here eschewing the use of META tags, advising instead to use http headers. I have no idea what they are or how to get to them, so I would appreciate some help. My...
1
by: Lakshmi Narayanan.R | last post by:
Hi Experts, In one SMS gateway project i need a great and urgent help from u all. There, the Service Providers sending the data thru "HTTP Headers" (For ex. sms-Id,sms-source ). So i need to...
1
by: John Smith | last post by:
I'm writing a service which accepts a POST call, updates a database and returns raw HTTP headers as specified below: HTTP/1.1 200 OK Content-type:text/plain Content-length:3 OK The code...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
8
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
2
by: sagar | last post by:
Hello Friends, I was working with Gdata to access the data in my google calander. I want to do this with a simple HTML-JS page, no server side scripting (hitherto dont know if this is...
10
by: rup | last post by:
Hello, This is my first application on socket programming in vc++. I am facing problem that how to make connection to server, & make GET/POST request by HTTP. Please help me. Its urgent.......
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.