I make a post request to the the page getremote.php with post data but the $_POST array seems to be empty. Would be grateful if anyone can tell me what I've done wrong.
The javascript code to make the request is
var postdata = "Content-Type: application/x-www-form-urlencoded\n\nedits=" + this.createEditXMLtext(this.editXMLstruct);
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
dispmes("processing edits");
xmlhttp.open("POST",userProfile.homeurl + "?remoteurl=" + userProfile.homeurl + "&cmdeditprofile&password=password",false);
xmlhttp.send(postdata);
var response = xmlhttp.responseXML;
where this.createEditXMLtext(this.editXMLstruct) simply creates a string
I haven't had this problem before and don't seem to have the same solution as other people who have posted similar problems. The php code at userProfile.homeurl + " is
header("Content-type: text/xml");
$query = '';
foreach( $_POST as $key => $value ){
$query .= "$key=$value&";
}
echo do_post_request($_GET['remoteurl'] . $qstring,$query);
but the string $query is always empty - I checked it by adding echo $query to the bottom of the file