我正在尝试使用 jQuery 将两个值传递给以下控制器操作
[HttpPost]
public JsonResult Cancel(Guid Id, string cancelReason)
{
//do something
}
.js:
CancelProgram = function (Id) {
//this is basically the value from a select tag placed on the form
var reason = $("#CancelReasons").val();
alert(reason);
Origin.ajax({
url: '/ZYX/Cancel?Id=' + Id,
type: 'POST',
dataType: 'json',
data: { cancelReason: reason },
success: function (data) {
alert('success!');
}
});
};
});
action 方法中的 cancelReason 的值始终为 null。关于为什么这不起作用的任何指示?