I am using MVC 3 and have an action that returns a JsonResult with 187 name value pairs (as a List<OrientationData>
), but often the data received from the ajax call is truncated and cannot be parsed.
This always returns the same 187 items via the JsonResult, so if it was a length issue, I'd think it would fail EVERY time. Here's the action:
[HttpPost]
public JsonResult GetAllMetrics()
{
var metrics = metric.GetAllMetrics();
return Json(metrics);
}
This is the jQuery ajax call:
$.ajax({
url: urlGetAllMetrics,
type: 'POST',
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (ajaxData) {
if (ajaxData && ajaxData.length > 0) {
//populate data here
}
},
error: function (msg) {
alert(msg);
}
});
The results returned to the ajax call are sometimes cut off and appear to actually cut off at 2 different places. What are some possible reasons for this?
I'd also like to note that when I use Fiddler to capture traffic, it works EVERY time without truncating the returned data (I have no idea why just yet). When I don't use Fiddler, I often receive an error in the ajax due to it being unable to parse the string to json. The data is an array with Value and Text string properties. The text being returned just cuts off:
...,{"Value":"h12","Text":"h12 name goes here"},{"Val