In one of my views in MVC 4.5 I have a jquery function that performs an ajax post to one of my controller methods. My data is 'stringified' json. For some reason, my controller method always limits my string lengths to 5325 characters. Once the string is sent to the controller, the application throws an error, because the JSON string isn't properly ended.
This is my jquery function:
$(function () {
$button.click(function () {
var selected = JSON.stringify($table.bootstrapTable('getSelections'));
$.ajax({
type: 'POST',
url: '/Hub/downloadWorkspaces',
data: 'selectedSpaces=' + selected,
success: function () {
window.location = '/Hub/browserMultiDownload';
}
});
});
});
The data is sent to one of my controller methods which is shown below:
[HttpPost]
public void downloadWorkspaces(string selectedSpaces)
{
System.Diagnostics.Debug.WriteLine(selectedSpaces);
JArray select = JArray.Parse(selectedSpaces);
for (int i = 0; i < select.Count; i++)
{
string selectedTest = select[i]["Workspace ID"].ToString();
Hub.Models.Query.getAllFiles(selectedTest);
}
}
For some reason, the selectedSpaces string is always cut off. What can I do to fix this?
...,"_Workspace ID_data":{"field":"Workspace ID"},"name":"CM.02.0002.MASPA_Conditional //No closing brace