473,721 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading data posted with XMLHttprequest

I'm trying to post a form (using POST not GET) using the xmlHttpRequest
object. I cannot work out how to get PHP (4.1.2) to read the data which
I'm submitting. Everything works fine if I use GET I can just read it
from $_GET. If I use POST nothing appears in $_POST.

To try to use the POST method I'm encoding the fields into a URL
encoded string and sending it as the parameter to the request.send()
function from Javascript. /Something/ is going out because I can see it
in the LiveHHTPHeaders extension to Firefox. Presumably it's being
received by the server. But how on earth do I get at it!? Been driving
me completely crazy.

Help!

--
Pete
====
*** Email is pete -at- dawnsun -dot- net
Jul 17 '05 #1
4 4429
Peter Gaunt wrote:
To try to use the POST method I'm encoding the fields into a URL
encoded string and sending it as the parameter to the request.send()
function from Javascript. /Something/ is going out because I can see
it in the LiveHHTPHeaders extension to Firefox. Presumably it's being
received by the server. But how on earth do I get at it!? Been driving
me completely crazy.


I have never worked with XMLHttpRequest, but when the data is posted and the
data doesn't show up in the $_POST array, it's probably sent as raw post
data.

To get this data, you should enable the always_populate _raw_post_data
directive in your php.ini file, after which you should be able to receive
the data through the $HTTP_RAW_POST_ DATA variable.
JW

Jul 17 '05 #2
Janwillem Borleffs wrote:
To get this data, you should enable the always_populate _raw_post_data
directive in your php.ini file, after which you should be able to receive
the data through the $HTTP_RAW_POST_ DATA variable.


Thanks!

Works a treat. I'd been hunting around all day for this information.

--
Pete
====
*** Email is pete -at- dawnsun -dot- net
Jul 17 '05 #3
y5
to use the $_POST global without enabling the raw data in php.ini, tr
the following code

objXMLHttpReque st.setRequestHe ader('Content-Type'
'application/x-www-form-urlencoded')
objXMLHttpReque st.send('var=va lue&var2=value2 ')

----
http://eye.cc -php- web design
Jul 17 '05 #4
y5 wrote:
to use the $_POST global without enabling the raw data in php.ini, try the following code:

objXMLHttpReque st.setRequestHe ader('Content-Type',
'application/x-www-form-urlencoded');
objXMLHttpReque st.send('var=va lue&var2=value2 ');


Or simply, file_get_conten ts('php://input');

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #5

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

Similar topics

7
7211
by: news.west.cox.net | last post by:
Forgive me, I am new to javascript ( about 1 week playing with it ). I am proficient in C, perl, python, java, etc... but no javascript. I wrote an applet about 1 million years ago that has dynamic drop down menus. I have a couple of C programs that take GET requested data and displays matching results from a database query... For example... www.mydomain.com/cgi-bin/getTypes?code=6 might display
0
1100
by: adamsbarker | last post by:
i have the following javascript code: --------- try{F=new ActiveXObject("Msxml2.XMLHTTP")} catch(e) { try{F=new ActiveXObject("Microsoft.XMLHTTP")} catch(e){F=typeof "XMLHttpRequest"!="undefined"?new XMLHttpRequest():0}
4
1406
by: J.D. | last post by:
Hello, I am working on a client project and they have a connection to a catalog system that passes data back and forth as xml over http The format of the data is as follow(s) > <?xml version="1.0"?> > > <customer-redemption>
1
2190
by: 4levels | last post by:
Dear Folks, I stumbled upon a strange behaviour of the XMLHttpRequest.. Maybe I'm just not well informed enough about its possibilities, so could someone please confirm my question? When I put plain javscript in a file that is read-in through a XMLHttpRequest-object, it's like it is totally ignored. Eg. I have the file ajax_include.html with in it's body the following lines <script type="text/javascript" language="javascript">
9
2255
by: ananttickoo | last post by:
hey !! .. i am new to thsi lang... i wanted to know how to read a file .. at remort location eg .. suppose a file http://www.url.com/update.txt is at a site and i am generating a page from http://url.com/index.html wo i want is that i get data of that page in my index.html page ..... i am iunable to do that can any one help me out here
1
5301
by: Tarik Monem | last post by:
OK, I'm pretty sure this cannot work because I'm trying to use JavaScript (client-side) to write to an xml file (which is server-side) using XMLHttpRequest. Can I use PHP do what I'm trying to do? Here's my code: The function mySaveFunction() is called by clicking the "Update" button, after the user changes the data which is populated in the form fields, which was retrieved via XMLHttpRequest from an XML external file. I know that...
2
4999
by: Wizfrog | last post by:
Hello, I'm working with a pretty large XML file, but I really only need to display a few things that requires quite a few transforms. I already limited to the transforms to the data i need to use, but I'd like to speed things up by loading only the data I need. I need to mention that this is for a local application that sometimes will lookup updates on a server, but mostly, it is for local use (offline)
0
8851
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8736
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9227
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6676
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5992
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3201
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 we have to send another system
2
2584
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.