简体   繁体   中英

Uncaught SyntaxError: Unexpected token :

I want to retrieve JSON data on my website. The problem is when I run the code I get an error:

Uncaught SyntaxError: Unexpected token :

My 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(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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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