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.

2
  • 1
    Try passing your formdata to the data parameter as an object instead of a string. Commented Dec 9, 2013 at 21:38
  • What's the server? Do you have any POST limits configured, e.g., stackoverflow.com/q/2943477/438992? Commented Dec 9, 2013 at 21:40

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.