开发者

getJSON() parameter length is more than 2500 for IE6 or IE7

I have a MVC web application. I am calling the controller method through the getJSON() method of the jquery.

    $.getJSON("applicationurl/controllerActionMethod", { parameter1: json, parameter2: jsonGrid, parameter3: value3, parameter4: value4 }, function(jsonResult) {

});
开发者_高级运维

Here I am passing the json values into the parameter1 and parameter2. The problem is that when length of the parameter2 is more than 2500 then it does call the controllActionMethod.

I have also used the $.ajax method instead of getJSON(), however it also does not work.


I'm assuming you mean it doesn't call the controller.

There is a maximum limit to GET requests (implemented in browsers, not servers); and 2500 is very close to it on some browsers.

You should consider making a POST request instead: http://api.jquery.com/jQuery.post, where the limit is much larger.

jQuery.post("applicationurl/controllerActionMethod", { parameter1: json, parameter2: jsonGrid, parameter3: value3, parameter4: value4 }, function(jsonResult) {

}, 'json');

Just to clarify, if you go over the GET length, the request should still be made; albeit truncated. I was edging towards some sort of server validation preventing the request.


You need to use post rather than get:

$.ajax({
    url: "applicationurl/controllerActionMethod", 
    data: { parameter1: json, parameter2: jsonGrid, parameter3: value3, parameter4: value4 },
    dataType: "json",
    type: "POST",
    success: function(jsonResult) {
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜