I am trying to return an MVC Model object to a JSON result using jQuery. I get an error like:
A circular reference was found while serializing an object of type "System.Reflection.RuntimeModule"
This is my controller where I save the Json result
public ActionResult populateData(string application, string columns, string machine, string pages, string startDate, string endDate)
{
ErrorPage _objError = new ErrorPage();
_objError.ErrorData = dbl.GetDataTable(DbConnectionString, Table, whereCondition, columns);
var columnlist = new Dictionary<string, System.Type>();
foreach (System.Data.DataColumn column in _objError.ErrorData.Columns)
{
var t = System.Type.GetType( column.DataType.FullName );
columnlist.Add(column.ColumnName, t);
}
_objError.ErrorColumns = columnlist;
if (_objError.ErrorData.Rows.Count > 0)
Message = "Showing Error log for " + AppName + " . To Change the application or filtering options please select the appropriate application from Application Dropdown";
else
Message = "No errors found for " + AppName + " in last 24 hours.";
return Json(_objError);
}
Here I am giving an Ajax call to the controller method:
$.ajax({
type: "POST",
url: '@Url.Content("~/Common/PopulateData")',
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: JSON.stringify({ application: app, columns: columns, machine: machine, pages: pages, startDate: startDate, endDate: endDate }),
success: function (data) {
alert("Success");
},
error: function (error) {
alert('error; ' + eval(error));
alert('error; ' + error.responseText);
}
});
Immediate help on how to return a model class object to an Ajax post post?
Anand source
share