خرید بک لینک

Vote count: 0

I try to make a simple JSON file get it using XMLHttpRequest.

I've debugged all I observed, but it still can't run, what's the problem here..

var getData = function() {

    var xmlhttp = new XMLHttpRequest();
    var url = "battletheme.json";

    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var themeinfo = JSON.parse(xmlhttp.responseText);
            showField(themeinfo);
        }
    };

    xmlhttp.open("GET", url, true);
    xmlhttp.send();
}

var showField = function(inputcat) {
    var txt = "";

    for(i=0; i<inputcat.length; i++) {
        txt += "Place: " + inputcat.field[i].fieldname + " , Boundary: " + inpucat.field[i].rightboundary + " <br>";
    }

    document.getElementById("msg_box").ierHTML = txt;

}

getData();

And the JSON file is here: (It's all in my computer and in the same root)

{"field": [
        {"fieldname" : "forest","leftboundary" : 1, "rightboundary" : 500},
        {"fieldname" : "jungle","leftboundary" : 1, "rightboundary" : 600},
        {"fieldname" : "island","leftboundary" : 1, "rightboundary" : 200}
]}

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 30 فروردين 1395 ساعت: 0:52

صفحه بندی