从URL Javascript加载/读取json

时间:2015-09-23 14:36:22

标签: javascript html json

我是JavaScript新手,我想从网址读取JSON信息,http://www.imobiliare.ro/sugestii/hunedoara

到目前为止,我已经完成了以静态方式解析信息,通过复制我访问该URL时的内容

看起来像这样:

<p id="demo"></p>

<script>


var text1 = '{"sugestii":[{"nume":"Hunedoara (tot jude&#355;ul)","id":"123220","tip":2},{"nume":"Hunedoara (din jude&#355;ul Hunedoara)","id":"126958","tip":1},{"nume":"Hunedoara Timisana (din jude&#355;ul Arad)","id":"14257","tip":1}]}' ;


obj = JSON.parse(text1);
document.getElementById("demo").innerHTML =
obj.sugestii[0].nume+ " ," + obj.sugestii[0].id+", " + obj.sugestii[0].tip;
</script>

我怎样才能做出类似他的

var text1 = "http://www.imobiliare.ro/sugestii/Hunedoara";

0 个答案:

没有答案