469,336 Members | 5,643 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

XMLHTTPRequest method POST appears not to be sent

gp
I have a an Ajax post sent to a php script on the server...the script
returns a response indicating that the _POST array wasn't set.

When I look at firebug, my headers appear to be ok, and the HTTP_POST
appears intact and doesn't appear out of sorts. And the response from
the PHP script is that of $_POST not being set.

function reqCocktailDetails(clid, cktlid) {
try {
var url = "http://<URL HERE>/process_xhr.php";
var str = "clid=" + clid + "&cktlid=" + cktlid;
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www=form-
urlencoded");
//http.setRequestHeader('Content-length', str.length);
//http.setRequestHeader('Connection', 'close');
http.onreadystatechange = hrGetDetails;
http.send(str);
} catch (err) {
var errorSpan = document.createNode("span");
$("divCktlPopUp_body").appendChild(errorSpan);
var errorTxt = err;
errorSpan.appendChild(errorTxt);
}
}

function hrGetDetails() {
if (http.readyState == 4) {
var responseTxt = http.responseText;
var respObj = eval("(" + responseTxt + ")");
var thisParentID = "divCktlPopUp_body";
if (!errorCheck(respObj, thisParentID)) {
buildCktlAddMod(respObj);
}
}
}

Mar 6 '07 #1
1 1501
gp
On 6 Mar, 09:36, "gp" <maxtha...@gmail.comwrote:
I have a an Ajax post sent to a php script on the server...the script
returns a response indicating that the _POST array wasn't set.

When I look at firebug, my headers appear to be ok, and the HTTP_POST
appears intact and doesn't appear out of sorts. And the response from
the PHP script is that of $_POST not being set.

function reqCocktailDetails(clid, cktlid) {
try {
var url = "http://<URL HERE>/process_xhr.php";
var str = "clid=" + clid + "&cktlid=" + cktlid;
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www=form-urlencoded");
//http.setRequestHeader('Content-length', str.length);
//http.setRequestHeader('Connection', 'close');
http.onreadystatechange = hrGetDetails;
http.send(str);
} catch (err) {
var errorSpan = document.createNode("span");
$("divCktlPopUp_body").appendChild(errorSpan);
var errorTxt = err;
errorSpan.appendChild(errorTxt);
}

}

function hrGetDetails() {
if (http.readyState == 4) {
var responseTxt = http.responseText;
var respObj = eval("(" + responseTxt + ")");
var thisParentID = "divCktlPopUp_body";
if (!errorCheck(respObj, thisParentID)) {
buildCktlAddMod(respObj);
}
}

}

I found the error of my ways....the obnoxiously minute typo strikes
again!!!
http.setRequestHeader("Content-type", "application/x-www=form-urlencoded");
NOTE: the "=" in "application/x-www=form-urlencoded"

REPLACE: with "-" to make it "application/x-www-form-urlencoded"

Mar 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Peter Gaunt | last post: by
5 posts views Thread by Börni | last post: by
6 posts views Thread by Chris Smith | last post: by
9 posts views Thread by Marcos | last post: by
1 post views Thread by Elizabeth Harmon | last post: by
5 posts views Thread by Peter Michaux | last post: by
1 post views Thread by geevaa | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.