Hi I have not found a sufficient answer for my problem. I need to return both json data and html from action result invoked by ajax.
$if (Request.IsAjaxRequest())
{
return Json(new
{
val1= Model.val1,
val2 = Model.val2,
val3= Model.val3,
Html = PartialView("_SearchResult", Model)
});
}
What do I have to do in ajax success part? This is bad try:
$.ajax({
type: "post",
dataType: "json",
url: actionUrl,
data: {
specs: selections,
params: parameters
},
success: function (response) {
$("#maincontent").html( response.html);
val1= response.val1;
val2= response.val2;
val3= response.val3;
},
error: function (xHR) {
alert(xHR.status);
}
});
Val1,2,3 are vars which I need to know because the model data are changing and I need to know this changed values. If you knew better solution how to return back values than json, let me know. But I need to return response html as well to update part of page. Thank you for helping me.