我有以下ajax调用:
$('#myModal').on('hidden.bs.modal', function () {
$.ajax({
url: '@Url.Action("UpdateCoverage", "Coverage")',
type: 'GET',
data: {},
success: function (result, status, xhr) {
alert("Result: " + status + " " + xhr.status + " " + xhr.statusText)
},
error: function (xhr, status, error) {
alert("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText)
}
});
})
...以及以下控制器方法:
public ActionResult UpdateCoverage()
//public async Task<ActionResult> UpdateCoverage(string searchTerm = null)
{
}
...我的控制器是
public class CoverageController : BaseController
...
我收到了错误结果。我做错了什么?
编辑:网址只是/ Coverage / UpdateCoverage。其余的如何确定,在本例中为localhost:50891 /? ajax调用是否必须进入View(cshtml)?
答案 0 :(得分:0)
var url='@(Url.Action("UpdateCoverage", "Coverage"))';
$.get(url, function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});