Well I hoped everything would work fine finally. But of course it doesn't. The new problem is the following message:
Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.
My fear is that I have to find another method of transmitting the data or is a solution possible?
Code of 开发者_Python百科XHR function:
function makeXHR(recordData)
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var rowData = "?q=" + recordData;
xmlhttp.open("POST", "insertRowData.php"+rowData, true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-Length",rowData.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
alert("Records were saved successfully!");
}
}
xmlhttp.send(null);
}
You should POST rowData
in the request body via the send
method. So, instead of posting to "insertRowData.php" + rowData
, POST to "insertRowData.php"
and pass the data in rowData
to send
.
I suspect that your rowData
is a query string with the question mark. If that is the case, then the message body is simply rowData
without the prepended question mark.
EDIT: Something like this should work:
var body = "q=" + encodeURIComponent(recordData);
xmlhttp.open("POST", "insertRowData.php", true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = // ...
xmlhttp.send(body);
精彩评论