I have the following dropdownlist defined –
@Html.DropDownListFor(x => x.SelectedValue, Model.myEntity, new { @id = "ddList" })
with the following jquery –
<script type="text/javascript">
$(document).ready(function () {
$("#ddList").change(function () {
var myid = $("#ddList").val();
$.ajax({
url: 'Controller/Action/',
data: {
'id': myid
},
datatype: 'html',
success: function (result) { success(result); }
});
});
});
function success(result) {
$("#partial").html(result);
}
</script>
every time that I change the selection in the drop down, it enters the controller correctly the first time.
If I then select the same option a second time, my controller action is never entered.
Does anyone have any idea why my code doesn’t hit the controller for any subsequent drop down selection.
Thanks
EDIT –
Here is the contents of the div partial – it actually renders an mvc partial view –
<div id="partial" style="height: 90%">
@Html.Partial("_Activities")
</div>
Looks like a caching issue to me. Caching is true by default in JQuery Ajax for data type HTML, set it to false. try this: