zoukankan      html  css  js  c++  java
  • ajax

    <script>
    $(document).ready(function(){
    $('#area_province').on('change', function(){
    //alert('好');
    var id = $(this).val();
    //alert('id='+id);
    var url = 'index.php?m=admin&c=area&a=children&id='+id;
    $.getJSON(url,function(data){
    //alert(data);
    //console.log(data);
    var option;
    if(typeof data == 'object'){
    //遍历data
    //option = data[0];
    $.each(data,function (key,value){
    //console.log(option);
    option +=('<option value="'+value.id+'">'+value.areaname+'</option>')
    });
    //将产生的option插入到文档中
    $('#area_city').html(option);//相当于innerHTML
    };
    });
    });
    $('#area_city').on('change', function(){
    //alert('好');
    var id = $(this).val();
    //alert('id='+id);
    var url = 'index.php?m=admin&c=area&a=children&id='+id;
    $.getJSON(url,function(data){
    //alert(data);
    //console.log('aaaa');
    var option;
    if(typeof data == 'object'){
    //遍历data
    option = data[0];
    $.each(data,function (key,value){
    //console.log(value);
    option +=('<option value="'+value.id+'" style="50px">'+value.areaname+'</option>')
    });
    //将产生的option插入到文档中
    $('#area_dist').html(option);//相当于innerHTML
    }
    });
    });
    });
    </script>

  • 相关阅读:
    POJ 1703 Find them, Catch them
    POJ 2236 Wireless Network
    POJ 2010 Moo University
    POJ 2184 Cow Exhibition
    POJ 3280 Cheapest Palindrome
    POJ 3009 Curling 2.0
    POJ 3669 Meteor Shower
    POJ 2718 Smallest Difference
    POJ 3187 Backward Digit Sums
    POJ 3050 Hopscotch
  • 原文地址:https://www.cnblogs.com/xdingc/p/6868755.html
Copyright © 2011-2022 走看看