I'm using the following Ajax call to load a partial view into a div:
$.ajax({
url: "/URL",
type: "POST",
dataType: "json",
data: JSON.stringify(request),
contentType: "application/json; charset=utf-8",
success: function(data) {
$('#Result').html(data);
App.hidePleaseWait();
},
error: function (jqXHR, textStatus, errorThrown) {
App.hidePleaseWait();
alert(textStatus);
alert(errorThrown);
}
});
Here's my controller:
[HttpPost]
public ActionResult GetSomething(MyModel formModel)
{
var model = new ResultModel();
try
{
model.Data = GetSomeData();
}
catch (Exception exception)
{
model.ErrorMessage = exception.Message;
}
return PartialView("_Results", model);
}
I get the following error "parserrror SyntaxError: Unexpected token <"
It seems that the .ajax call is expecting json back instead of html. What do I need to do to fix this?
Thanks.