Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获的语法错误:意外标记:_Javascript_Jquery_Json - Fatal编程技术网

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

Javascript 未捕获的语法错误:意外标记:,javascript,jquery,json,Javascript,Jquery,Json,我想在我的网站上检索JSON数据。问题是,当我运行代码时,我得到一个错误: 未捕获的语法错误:意外标记: 我的JSON: { "metadata": { "language": "en-US", "transaction_id": "1464687780497:-1422910090", "version": "1", "latitude": 33.26, "longitude": 44.23,

我想在我的网站上检索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
    }
}
我的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
jQuery(文档).ready(函数)(天气){
$.ajax({
url:“http://meteoiraq.com/warring.json",
数据类型:“jsonp”,
成功:功能(数据){
对于(var i=0;i
我认为下面的代码会起作用

尝试使用ajax的getJSON方法,并尝试将“#deatils”更改为“#details”,因为我猜您可能拼写错误了确切的名称


希望这能有所帮助。

为什么您的数据类型是
jsonp
?另外,
length
属性适用于数组和
数据。元数据
不是数组。因此,您可以从DOMReady处理程序函数定义中删除
weather
属性。