XMLHTTPRequest method POST appears not to be sent

G

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);
}
}
}
 
G

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);
}
}

}


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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top