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&client_email=foo@bar.com&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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.