nodejs三级联动

标题

html## 标题

Document
<script type="module">

    import QueryString from "../js/QueryString.js";

    var citiesId, countiesID, id, perform, Plist,arr6 =[] ,arr5 = [], arr1 = [], arr2 = [], arr3 = [], arr4 = [];
    init();
    function init() {
        ajax("province")
    }
    function ajax(type, data) {
        if (data === undefined) data = "";
        data = QueryString.stringify(data);
        var xhr = new XMLHttpRequest();
        xhr.addEventListener("load", loadHanlder);
        xhr.open("GET", "http://10.9.72.249:4900/" + type + "/?" + data);
        xhr.send();
    }

    function loadHanlder(e) {
        var xhr = e.currentTarget;
        xhr.removeEventListener("load", loadHanlder);
        var type = xhr.responseURL.trim().split("?")[0];
        if (type.slice(-1) === "/") type = type.slice(0, -1);
        type = type.split("/").pop();
        var o = JSON.parse(xhr.response);
        Plist = o.provinceList
        citiesId = o.citiesList
        countiesID = o.countiesList
        createList(Plist);
    }

    function createList(data) {
        var select1 = document.querySelector("#province");
        var frg = document.createDocumentFragment()
        for (var i = 0; i < data.length; i++) {
            var option = document.createElement('option')
            option.textContent = data[i].provinceName
            frg.appendChild(option)
        }
        select1.appendChild(frg)
        select1.addEventListener("change", changeHandler);
        console.log(data[0].cities)
        for (let i = 0; i < data[0].cities.length; i++) {
            citiesId.forEach(item => {
                if (item.id === data[0
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值