javascript - Uncaught ReferenceError: Bind_ChainHotel is not defined -
i've defined function named bind_chainhotel in javascript on alter of dropdown selection, fill info dropdown through ajax. using htmlhelper.dropdownlist in mvc5. whenever select alternative got error in console.
@html.dropdownlist("ddlshelllevel", new list<selectlistitem> { new selectlistitem{text="chain",value= "1"}, new selectlistitem{text="hotel",value= "2"} }, "select level", new { onchange = "bind_chainhotel(this.value);", @class = "form-control" })
javascript
(function bind_chainhotel(id) { $.ajax({ url: '@url.action("bind_chainhotel", "shell")', type: "post", data: { "id": id }, success: function (data) { $("#ddlchain_hotel").empty(); $.each(data, function (i, chain_hotel) { $("#ddlchain_hotel").append('<option value="' + chain_hotel.value + '">' + chain_hotel.text + '</option>'); }); if (id == 1) { $('#lblchainhotel').text('select chain'); $("#ddlchain_hotel").prepend('<option value="0">select chain</option>'); } else { $("#lblchainhotel").text("select hotel"); $("#ddlchain_hotel").prepend('<option value="0">select hotel</option>'); } } }); })();
remove leading , ending parenthesis
function bind_chainhotel(id) { $.ajax({ ..... }); };
javascript c# jquery asp.net-mvc-5
No comments:
Post a Comment