I have the following JQuery code in an attempt to populate a dropdown list:
<script language="javascript" type="text/javascript">
$(function(){
$("#setStatusDrpDown").change(function(){
$.getJSON("getStatusChangeReasons",
{selectedStatusId: $(this).val(), ajax: 'true'},
function(result) {
alert("here");
for (var i = 0; i < result.length; i++) {
alert("hello");
options += '<option value="' + result[i].id + '">' + result[i].changeReason + '</option>';
}
$("select#statusChangeReason").html(options);
});
});
});
</script>
I know that the code is running because I can see my controler intercept it and even print the selectedStatusId value. What I cannot figure out is why neither of my alerts are displayed. I don’t see any errors on the javascript console. Its as if code simply quits execution after the controller. Any advice is apprecaited!
Your service might be throwing an error or returning something that $.getJSON can’t understand.
You can handle the error withe xhr return value.