There is no such limit on the string length. To be certain, I just tested to create a string containing 60 megabyte.
The problem is likely that you are sending the data in a GET request, so it's sent in the URL. Different browsers have different limits for the URL, where IE has the lowest limist of about 2 kB. To be safe, you should never send more data than about a kilobyte in a GET request.
To send that much data, you have to send it in a POST request instead. The browser has no hard limit on the size of a post, but the server has a limit on how large a request can be. IIS for example has a default limit of 4 MB, but it's possible to adjust the limit if you would ever need to send more data than that.
Also, you shouldn't use += to concatenate long strings. For each iteration there is more and more data to move, so it gets slower and slower the more items you have. Put the strings in an array and concatenate all the items at once:
var items = $.map(keys, function(item, i) {
var value = $("#value" + (i+1)).val().replace(/"/g, """);
return
'{"Key":' + '"' + Encoder.htmlEncode($(this).html()) + '"' + ",'+
'" + '"Value"' + ':' + '"' + Encoder.htmlEncode(value) + '"}';
});
var jsonObj =
'{"code":"' + code + '",'+
'"defaultfile":"' + defaultfile + '",'+
'"filename":"' + currentFile + '",'+
'"lstResDef":[' + items.join(',') + ']}';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…