我正在尝试使用MVC4 Web应用程序中的jQuery Ajax将下拉列表中选定项的值发回给控制器中的Action方法。我有一个名为MeditechDropDown的下拉列表,这是我的jQuery函数,无法正常运行。我设法达到了我的Action方法,但传入的值为null。
jQuery(document).ready(function () {
$("#MeditechDropDown").change(function () {
$.ajax({
url: "/Home/PopulateEmailAddressUI",
data: JSON.stringify('id=' + $(this).val()), // Send value of the drop down change of option
type: 'POST',
contentType: 'application/json; charset=utf-8',
success: function (data) {
// Variable data contains the data you get from the action method
}
});
});
});
操作名称是PopulateEmailAddressUI。有人能告诉我我做错了什么吗?我知道我没有正确编写我的jQuery函数。非常感谢。
这是完整的jQuery工作脚本:
jQuery(document).ready(function () {
$("#MeditechDropDown").change(function () {
var id = $(this).find(":selected").val()
var clientID = { "clientID" : id }
console.log(id)
$.ajax({
url: "/Home/PopulateEmailAddressUI",
data: JSON.stringify(clientID),
type: 'POST',
contentType: 'application/json; charset=utf-8',
success: function (data) {
// Variable data contains the data you get from the action method
}
});
});
});
谢谢大家,尤其感谢zgood :)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句