未捕获的TypeError:无法读取未定义EERROOR的属性'forEach'

时间:2019-04-18 20:21:04

标签: javascript html

myArr.forEach,无法读取未定义错误的属性“ forEach”

var hhtpistegi = new XMLHttpRequest();
var adres = "https://raw.githubusercontent.com/hiiamrohit/Countries-States-Cities-database/master/countries.json";

hhtpistegi.onreadystatechange = function () {
    if (this.readyState == 4 && this.status == 200) {
        var myArr = JSON.parse(this.responseText);
        var bolgeSlc = document.getElementById('Bolgeler');
        myArr.forEach(myArr => {
            bolgeSlc.innerHTML += '<option> ' + myArr.name + ' <option>'
        });
    }
};
hhtpistegi.open("GET", adres, true);
hhtpistegi.send();

HTML代码连接

<div class="field">
       <div class="control">
              <select id="Bolgeler"></select>       
            <input type="button" onclick="UlkeleriGetir()" value="ulkleri listele" />
        </div>
</div>

0 个答案:

没有答案