从文件中检索JSOn dtat不成功 [英] Retrieve JSOn dtat from file not successful

查看:100
本文介绍了从文件中检索JSOn dtat不成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML中,我嵌入了以下代码段。 json_PointList2.json文件位于HTML文件的同一文件夹中。但是,调试器没有命中。请指出这个脚本有什么问题?非常感谢。

In a HTML, I embedded the piece of code below. The json_PointList2.json file is in the same folder of the HTML file. However, no hit happens at the debugger. Please point out what is wrong in this script? Thanks in adavnce.

var polylineJson2;
    $.ajax ( {
    type:'Get",
    url:'json_PointList2.json',
    dataType:'json',
    data:{},
    crossDomain : true,
    success:function(results) {
                console.log('Success!');
                debugger;
                polylineJson2 = results;
    },
    error: function(xhr, status, error) {
                debugger; console.log(error);
    }
} );

推荐答案

.ajax({
type:' 获取,
url:'
json_PointList2.json '
dataType:'
json '
data:{},
crossDomain:true,
success:function(results) ){
console.log('
成功!' );
调试器;
polylineJson2 = results;
},
错误:函数(xhr,状态,错误){
debugger;的console.log(误差);
}
});
.ajax ( { type:'Get", url:'json_PointList2.json', dataType:'json', data:{}, crossDomain : true, success:function(results) { console.log('Success!'); debugger; polylineJson2 = results; }, error: function(xhr, status, error) { debugger; console.log(error); } } );


这是猜测。可能在代码中缺少redy()方法。尝试如下。



This is a guess.May be missing redy() method in your code.Try is as below.

<script type="text/javascript">


(document).ready(function( ){

var polylineJson2;
(document).ready(function() { var polylineJson2;


这篇关于从文件中检索JSOn dtat不成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆