简体   繁体   English

未捕获的语法错误:意外标记:

[英]Uncaught SyntaxError: Unexpected token :

I want to retrieve JSON data on my website.我想在我的网站上检索 JSON 数据。 The problem is when I run the code I get an error:问题是当我运行代码时出现错误:

Uncaught SyntaxError: Unexpected token :未捕获的语法错误:意外标记:

My JSON:我的JSON:

{
    "metadata": {
        "language": "en-US",
        "transaction_id": "1464687780497:-1422910090",
        "version": "1",
        "latitude": 33.26,
        "longitude": 44.23,
        "units": "m",
        "expire_time_gmt": 1464688380,
        "status_code": 200
    }
}

My jQuery我的jQuery

jQuery(document).ready(function (weather) {
    $.ajax({
        url: "http://meteoiraq.com/warring.json",
        dataType: "jsonp",
        success: function (data) {
            for (var i = 0; i < data.metadata.length; i++) {
                html += '<h1 class="text-center">التحذيرات الجوية</h3>';
                html += '<h2>' + data.metadata.language + '</h2>';
                html += '</div>';
                $("#deatils").append(html).hide().fadeIn("slow");
                //next ho
            }
        }
    }); //add this code. Need to close the 'jQuery(document)'
}); // a

I think below code will work我认为下面的代码会起作用

try Using getJSON method of ajax and also try changing "#deatils" to "#details" as i guess you might be mis-spelling the exact name尝试使用 ajax 的 getJSON 方法,并尝试将“#details”更改为“#details”,因为我猜您可能拼错了确切的名称

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM