日期:2014-05-16  浏览次数:20414 次

通过js读取url json数据,并在网页上显示出来
用js原生的方法实现,不要用jquery,url是http://fxinfo.api.fxhelper.cn/news/bignewnews.js,该怎么写?

------解决方案--------------------
 

<div id="body" ></div>
<script>
  var url="http://fxinfo.api.fxhelper.cn/news/bignewnews.js"
  var req=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
  req.open("GET",url,false);
  req.send(null);
  eval( ' var data='+ req.responseText);
  var html=[];
  for(var i=0;i< data.length;i++ ){
   html.push( '<li>title:'+ data[i].Value.strtitle +'</li>' );
  }
  document.getElementById('body').innerHTML=html.join('');
 </script>