Click on the province to display the corresponding city

New jquery code:

$("#provinces").change(function() {
    $.ajax({
        type: "get",
        url: "region_action.php", // type =2表示查询市
        data: {"parent_id": $(this).val(), "type": "2"},
        dataType: "json",
        success: function(data) {
            $("#citys").html("<option value=''>请选择市</option>");
            $.each(data, function(i, item) {
                $("#citys").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
            });
        }
    });
});

each() traverses json to object.

Effect exhibit:

微信图片_20180310115908.png

Continuing Learning
||
<?php echo "市区的触发显示";
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!