Auto-populating select boxes using jQuery and Ajax - not working in anything newer than 1.3.2

后端 未结 4 1024
粉色の甜心
粉色の甜心 2021-01-16 04:35

I have been going through this tutorial on auto-populating boxes using jQuery and Ajax: http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/

4条回答
  •  情书的邮戳
    2021-01-16 04:59

    Assuming your json is valid you should be able to use the following:

     $("select#ctlJob").change(function(){
        $.getJSON("/select.php",{id: $(this).val(), ajax: 'true'}, function(data){
          var $persons = $("#ctlPerson").empty();
          $.each(data, function() {
            $persons.append("");
          });
        })
      });
    

    Updated to use your markup in the question on jsfiddle.

提交回复
热议问题