已经为此苦苦挣扎了一天多,我如何将 actionlink id 传递给 jquery ajax 调用以启用部分页面更新。
<li>@Html.ActionLink(@item.strCountry, "Index", "Weather", new { id = Regex.Replace(@item.strCountry, " ", "-") }, new { @class = "getCities" })</li>
jQuery
<script>
$(function () {
$(".getCities").click(function () {
$.ajax({
//url: this.href,
url: '@Url.Action("pvDisplayListOfWeatherCities", "Weather")',
type: 'GET',
data: { id: $('#id').val() },
dataType: 'Json',
success: function (result) {
alert(result.test);
},
error: function () {
alert("error");
}
});
return false;
});
});
</script>
谢谢
乔治