asp.net mvc - Parse json and populate dropdown by jquery -


this json return server side mvc controller.

[{"id":"al","name":"alabama"},{"id":"fl","name":"florida"},{"id":"ia","name":"iowa"},{"id":"ms","name":"mississippi"}] 

this way trying parse , trying populate dropdown jquery.

 $(function () {         $('#countryid').change(function () {             var dropdownid = $(this).val();             $.post('@url.action("index", "home")', { countryid: dropdownid }, function (result) {                  $("#state").html("");                 (var = 0; < result.length; i++) {                     var item = result[i];                     $("#state").append(               $("<option></option>").val(item.id).html(item.name)         );                 }                 //$('#state').html(items);                 $("#state").prop("disabled", false);             });         });     }); 

a wired error coming form jquery code follow , capture firebug console

typeerror: $(...).prop not function [break on error]     ..."alabama"},{"id":"fl","name":"florida"},{"id":"ia","name":"iowa"},{"id":"ms","na... 

i not being able figure out. if possible please tell me kind of mistake making in code. thanks

try this

$("#state").prop("disabled", false); 

change to

$("#state"d).removeattr('disabled'); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -