我是JavaScript新手,我想从网址读取JSON信息,http://www.imobiliare.ro/sugestii/hunedoara
到目前为止,我已经完成了以静态方式解析信息,通过复制我访问该URL时的内容
看起来像这样:
<p id="demo"></p>
<script>
var text1 = '{"sugestii":[{"nume":"Hunedoara (tot judeţul)","id":"123220","tip":2},{"nume":"Hunedoara (din judeţul Hunedoara)","id":"126958","tip":1},{"nume":"Hunedoara Timisana (din judeţ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";