I have ajax action link in my view :
@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" }
)
i have drop down control on my page. User can select dropdown and after clicks on ajax link above and parameter from dropdown should be sent to controller action.
in my javascrip file i have:
$("#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());
}
});
on click i want to add parameter to ajax action link. So click event is recognized so this is ok but "return this.href.replace('x', $('#ddState').val());" this line of code says "cannot read property replace of undefined". Help please :/