Javascript 未捕获的语法错误:意外标记:
我想在我的网站上检索JSON数据。问题是,当我运行代码时,我得到一个错误: 未捕获的语法错误:意外标记: 我的JSON: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,
{
"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
属性。