Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.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
使用anyorigin获取javascript中的JSON_Javascript_Jquery_Json_Fetch - Fatal编程技术网

使用anyorigin获取javascript中的JSON

使用anyorigin获取javascript中的JSON,javascript,jquery,json,fetch,Javascript,Jquery,Json,Fetch,我正在尝试获取数据,但下面的脚本不起作用。你能帮我弄清楚吗 function initialize() { $.getJSON('http://anyorigin.com/get?url=http%3A//www.wawhost.com/appProject/fetchmarker.php&callback=?', function (data) { localStorage.jsontext = data.contents; }); } localStorage.jsontext =

我正在尝试获取数据,但下面的脚本不起作用。你能帮我弄清楚吗

function initialize() {
$.getJSON('http://anyorigin.com/get?url=http%3A//www.wawhost.com/appProject/fetchmarker.php&callback=?', function (data) {
localStorage.jsontext = data.contents;
});
}

localStorage.jsontext = localStorage.jsontext.replace('(', '{"temp":');
localStorage.jsontext = localStorage.jsontext.replace(')', '}');

obj = JSON.parse(localStorage.jsontext);

for(var i=0;i<=5;i++) {
document.write('<img src="' + obj.temp[i].image + '" />');
document.write(obj.temp[i].id);
document.write(obj.temp[i].location);
document.write('<br>');
}
函数初始化(){
$.getJSON('http://anyorigin.com/get?url=http%3A//www.wawhost.com/appProject/fetchmarker.php&callback=?,函数(数据){
localStorage.jsontext=data.contents;
});
}
localStorage.jsontext=localStorage.jsontext.replace(“(”,“{”temp:”);
localStorage.jsontext=localStorage.jsontext.replace(')','}');
obj=JSON.parse(localStorage.jsontext);

对于(var i=0;i您确实意识到
http://www.wawhost.com/appProject/fetchmarker.php
提供jsonp

function initialize() {
    $.getJSON('http://www.wawhost.com/appProject/fetchmarker.php?callback=?', function (data) {
        for(var i=0;i<data.length;i++) {
            document.write('<img src="' + data[i].image + '" />');
            document.write(data[i].id);
            document.write(data[i].location);
            document.write('<br>');
        }
    });
}
initialize();
函数初始化(){
$.getJSON('http://www.wawhost.com/appProject/fetchmarker.php?callback=?,函数(数据){

因为(var i=0;i你是最棒的!!非常感谢!