views:

33

answers:

1

Hi, Is there a size limit to a XHR POST request? I am using the POST method for saving textdata into MySQL using PHP script and the data is cut off. Firebug sends me the following message:

... Firebug request size limit has been reached by Firebug. ...

This is my code for sending the data:

function makeXHR(recordData) { xmlhttp = createXHR();

var body = "q=" + encodeURIComponent(recordData);

xmlhttp.open("POST", "insertRowData.php", true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", body.length);
xmlhttp.setRequestHeader("Connection", "close");

xmlhttp.onreadystatechange = function() 
{
    if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
    {
        //alert(xmlhttp.responseText);
        alert("Records were saved successfully!");
    }
}
xmlhttp.send(body);

}

The only solution I can think of is splitting the data and making a queue of XHR requests but I don't like it. Is there another way?

A: 

XHR Post has no size limit, but you're sending data to PHP which has a size limit ;) Create the following php-file and open it in a browser:

<?php phinfo(); ?>

Now search for the variable "post_max_size", this variable limits the maximum data that can be sent to PHP (but it can be changed in the php.ini)

Tobias P.
Hi, my initial value for "post_max_size" was 8M and I increased it to 80M and restarted the server. This is not the problem I think because the data will never reach 8M in the first place ...
Only because Firebug has problems with this filesize does not mean it doesn't work ;)Have you checked if the js-code works when the firebug-console is not active?
Tobias P.
I have a suspicion where the problem is. I use a XHR GET method for retrieving the data and GET is limited:function retrieveRows(){xmlhttp = createXHR(); xmlhttp.open("GET","retrieveRowData.php", false); try{ xmlhttp.send(null);}catch(err){ errormessage="There was an error on this page.\n\n"; errormessage+="Error description: " + err.description + .\n\n"; errormessage+="Click OK to continue.\n\n"; alert(errormessage); } return xmlhttp.responseText;}