Ashwin
Ashwin

Reputation: 12421

javascript character limit for a string sent by post

I am creating a string variable in javascript and the length of that string could be any.

I am sending this string by jquery post method to a servlet. This servlet writes the string to a file.

I can alert the string anywhere in my javascript and can see the complete string.

But whenever the string length exceeds 5345 characters, then I get "aborted" message in firebug (I assume data is not sent) and no error message is displayed in server's console. (For chrome, length limit is little more i.e. 5389)

I guess there is a problem in length of the data that is being sent to the servlet. But I wonder, to my knowledge there is no limit to the amount of data sent by post.

I am using jquery's $.post method as below

$.post('servlet', function(data) {

});

I want to print the error that has occurred while sending data to the servlet. Can I do that?

Upvotes: 1

Views: 1984

Answers (1)

Mehul Hingu
Mehul Hingu

Reputation: 1240

If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path.

However, the POST method is not limited by the size of the URL for submitting name/value pairs. These pairs are transferred in the request body and not in the URL.

Upvotes: 1

Related Questions