Re: Parsing AJAX post data -- The Way
| From: | M5 | Date: | Thu, 25 Jan 2007 19:13:35 +0000 |
| Subject: | Re: Parsing AJAX post data -- The Way | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247789@lists.php.net to get a copy of this message | ||
On 25-Jan-07, at 7:49 AM, Myron Turner wrote:
m5@renefournier.com / 2007-01-24 23:41:19 -0700:Yes, that is the trick, thank you. I didn't realize sending the correct header would then make $_POST do it's magic with "&var=arg into an array", but now it works as desired. Thanks everyone for the assistance. ...ReneTry setting this header before sending your Ajax request: http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); Then $_POST should have an array, as expected. But $HTTP_RAW_POST_DATA will not be available.Just wondering what smart people do for parsing data sent by the Javascript XMLHTTP object--e.g., http.send("post",url,true)... In a normal form submit, the $_POST global nicely allocates form elements as array elements automatically. But with the AJAX way, the data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby making extraction more tedious.