【发布时间】:2014-02-24 18:18:42
【问题描述】:
这把我彻底难住了。好奇怪。
我已经定义了这个 Ajax 函数:
$.ajax({
type: 'GET',
dataType: 'text/HTML',
url: getLicenseeDetailsUrl,
success: function (response) {
$('#licenseeDetails').html('');
$('#licenseeDetails').html(response);
},
error: function (xhr) {
alert('Failed to get licensee details');
}
});
我让它调用我的控制器,它的动作如下:
public ActionResult LoadLicenseeDetails(long licenseeId)
{
var model = new LicenseeDetailsViewModel();
var licencesee = _licensingRepository.LoadById(licenseeId);
var licenses = _licensingRepository.LoadLicenses(licenseeId);
model.Licencee = Mapper.Map<Licensee, LicenceeViewModel>(licencesee);
model.Licences = Mapper.Map<IEnumerable<License>, IEnumerable<LicenceViewModel>>(licenses);
return this.PartialView("_LicenseeDetails", model);
}
这一切似乎都按预期工作,没有任何错误,但它最终触发了 Ajax 错误函数,而不是成功函数。
查看xhr.responseText我可以看到来自动作控制器的正确响应信息!!
所有状态都为 200 OK。我到底做错了什么?
【问题讨论】:
标签: javascript jquery ajax asp.net-mvc