Populating dropdown menu with JSON Data

前端 未结 4 1691
忘了有多久
忘了有多久 2020-12-19 19:49

I\'m tyring to use AJAX to populate a dropdown box based on the selection of another dropdown. I followed a tutorial using jQuery located here - http://remysharp.com/2007/01

4条回答
  •  一整个雨季
    2020-12-19 20:02

    Since JSON can be considered as associative array also, you may do smth like this:

    $(function(){
            $("select#ContactCompanyId").change(function(){
              $.getJSON("contactList",{id: $(this).val(), ajax: 'true'}, function(j){
                var options = '';
                for (key in j) {
                    options += '';
                }
                $("select#QuoteContactId").html(options);
                })
            })
    })  
    

    More info about JSON can be found in this article - "Mastering JSON"

提交回复
热议问题