【发布时间】:2014-08-21 20:57:49
【问题描述】:
我的视图中有 ajax 操作链接:
@Ajax.ActionLink("ShowWithFilter",
"ShowCompanyData",
null,
new { StateId = "x", CityId = "y" },
new AjaxOptions
{
HttpMethod = "GET", // HttpMethod to use, GET or POST
UpdateTargetId = "PartialView", // ID of the HTML element to update
InsertionMode = InsertionMode.Replace, // Replace the existing contents
OnBegin = "setParameters",
}, new { id = "linkFilter" }
)
我的页面上有下拉控件。用户可以选择下拉菜单,点击上面的 ajax 链接后,下拉菜单中的参数应发送到控制器操作。
在我的 javascrip 文件中:
$("#linkFilter").click(function (e) {
if ($("#ddState").prop("disabled", false)) {
$('#linkFilter').attr('href', function () {
return this.href.replace('x', $('#ddState').val());
});
}
else if ($("#ddCity").prop("disabled", false)) {
return this.href.replace('y', $('#ddCity').val());
}
});
单击时我想将参数添加到 ajax 操作链接。所以点击事件被识别所以这没关系但是“return this.href.replace('x', $('#ddState').val());”这行代码说“无法读取未定义的属性替换”。请帮忙:/
【问题讨论】:
标签: jquery asp.net-mvc html.actionlink