我有以下代码,它指出错误如下
错误1当前上下文中不存在名称“日期” 错误2当前上下文中不存在名称“person”
有什么问题?
$("#test").Click(function () {
var date = $("#DateFrom").val();
var person = Model.SelectedPerson;
$.ajax({
url: '@Url.Action("testEmp","Employee",new {dateFrom = date, selectedPerson= person})',
type: 'GET',
contentType: "application/json; charset=utf-8",
dataType: "html",
success: function (result) {
$('#text).html(result);
},
});
return false;
});
答案 0 :(得分:0)
试试这个:
$.ajax({
url: '@Url.Action("ActionName")',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ date: '..', person: '...' }),
success: function(result) {
}
});
编辑:请查看此答案以获取完整的解决方案 jquery ajax forms for ASP.NET MVC 3