I call my MVC controller action via Ajax, and want the action to return two partial views. Both partial views should be returned as html.
This is how I call via ajax
$.ajax({
url: '/SomeController/GetContent',
type: 'GET',
dataType: "html",
success: function (d, status, xhr) {
$('#partial1') = d.?
$('#partial2') = d.?
},
error: function (req, status, errorObj) {
alert('error');
}
});
I tried something like this for the controller action:
public PartialViewResult[] GetContent()
{
PartialViewResult[] pvs = new PartialViewResult[2];
pvs[0] = PartialView("Partial1", null);
pvs[1] = PartialView("Partial2", null);
return pvs;
}
It works if I simply return one partial view (not returning as an array), but for two I just get an empty array returned in the ajax success. Any ideas how to solve this?
pvsas json array can loop over array and insert into appropriate elements. AdjustdataTypeaccordingly