Jump to content

[SOLVED] Ajax not sending post data?


jordanwb

Recommended Posts

This is my first time using Ajax seriously, so my fail may be incredibly simple. I have the following JavaScript function:

 

function SendQuoteRequest ()
{
if (CheckForm ())
{
	var request = GetHxrObject ();

	if (request)
	{
		request.open("POST", "http://99.224.34.94/~jordanwb/quote/quote_request.php", true);
		request.onreadystatechange = function () { UpdatePage(request); };
		request.send(PreparePostData ());
	}
	else
	{
		alert ("Your browser does not support AJAX. If you are using a very old browser, please consider upgrading it.");
	}
}
}

 

The request goes through, but on the server side there is no POST data. The post data being sent is like so:

 

client_name=Foo&[email protected]&client_info=a&0[type]=1&0[locale]=1&0[width]=5&0[height]=5&0[mount]=1

 

This is the backend PHP:

 

<?php

$file = fopen ("post_info.txt", "w");

fwrite ($file, print_r ($_POST, true));

fclose ($file);

?>

 

The text that is written is simply:

 

Array
(
)

 

You can access the whole thing at http://99.224.34.94/~jordanwb/quote/quote.htm

Link to comment
https://forums.phpfreaks.com/topic/175027-solved-ajax-not-sending-post-data/
Share on other sites

According to Firebug the POST data is being sent, but it never gets to the PHP. I changed

 

request.send(PreparePostData ());

 

to simply

 

request.send("foo=bar&bar=foo");

 

but PHP doesn't get the POST data. It doesn't seem to be a configuration error because a dummy form I made works: http://99.224.34.94/~jordanwb/test

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.