0

I'm posting four JSON objects to the server using a jQuery ajax request. Each object can be up to 30k characters. When all of the parameters are large the last parameter or even the last two parameters do not show up on the server. Everything works fine when the parameters are smaller though.

In chrome's network tab I see all of the parameters in their entirety. In fiddler I see the parameters in their entirety but the parameters that don't show up on the server will not have a name.

Fiddler

fiddler snippit

The structure of my request is as follows:

var formData = "json0=" + JSON.stringify(json0) + "json1=" + JSON.stringify(json1); //etc
$.ajax({
    type: 'POST',
    url: url,
    data: formData,
    success: function (result) {},
    error: function() {}
});

I wouldn't think there would be a limit on a POST but it's acting like the data is being truncated for some reason. Server side I'm in Java using ParameterAware to retrieve the data but I think the issue is before it gets there since fiddler doesn't have the parameters' names.

scrowler
  • 24,273
  • 9
  • 60
  • 92
user1134179
  • 539
  • 1
  • 12
  • 24

1 Answers1

2

Query strings are not made for large amounts of data, you should pass your data to your Ajax call in an object:

$.ajax({
    type: 'POST',
    url: url,
    dataType: "JSON",
    data: {
        json0: json0,
        json1: json1
        // etc
    },
    success: function (result) {},
    error: function() {}
});

Have a look at this article discussing the maximum length of query strings.

jQuery AJAX documentation: http://api.jquery.com/jQuery.ajax/

Community
  • 1
  • 1
scrowler
  • 24,273
  • 9
  • 60
  • 92
  • Although this works it was not the problem. I didn't want to do this because I like consistency and the paradigm in my post is used in many places. It turns out there was some weird character sequence that was breaking the formatting of the queryString. After encoding in the js and decoding on the server all is good. – user1134179 Dec 10 '13 at 04:52