I've been struggling to send an array of Document objects from a method (let's say it's in a controller) to the JavaScript function where the method is being called (in a view). Oddly enough, the method refuses to pass the array - it only works when the array is empty. I even attempted to pack all the array elements into a new array or a list and transfer it to the view, but to no avail (Inspect Element -> Console = 500 Internal Server Error) (Link to Screenshot).
Below is a snippet of the JavaScript code:
$.ajax({
method:"get",
data: data,
url: url + "?binderId=" + companyId +"&description="+ data
}).success(function (response) {
console.log("Success");
console.log(response);
}).error(function (response) {
console.log("Error");
console.log(response);
});
And here is the C# code responsible for sending the array to the aforementioned JavaScript function:
public ActionResult SearchDocument(int binderId, string description)
{
//documents is an array
var documents = Search.SearchDocument(binderId, description);
return Json(documents, JsonRequestBehavior.AllowGet);
}
I believe there may be an issue with the JavaScript implementation, but I'm not entirely sure. Any help would be greatly appreciated!