请教大侠 获取JSON返回数据问题
<script type="text/javascript">
<!--
var xmlhttp;
// 创建XMLHTTPRequest对象
function createXMLHTTPRequest()
{
if(window.ActiveXObject)//②如果当前浏览器为IE
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHTTPRequest)//③如果是其他浏览器
{
xmlhttp = new XMLHTTPRequest();
}
}
function getInfo()
{
var bh =document.getElementById("bh").value;
var name=document.getElementById("name").value;
createXMLHTTPRequest();
if ((bh == null) || (bh == "")) return;
var url = "1.asp?bh=" + escape(bh);
url=url + "&name=" + name;
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = returnInfo;
xmlhttp.send(null);
}
function returnInfo()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var info = xmlhttp.responseText;
// shownr.innerHTML = info;
//返回 info = {"traderates_get_response":{"trade_rates":{"trade_rate":[{"content":"很好!","nick":"平地","result":"good","valid_score":false},{"content":"不错!","nick":"平地","result":"good","valid_score":true}]},"total_results":2}}
showscore.innerHTML = valid_score;
shownick.innerHTML = nick;
showcontent.innerHTML = content;
showresult.innerHTML = result;
}
}
-->
</script>
<input name="bh" type="hidden" id="bh" >
<input name="name" type="hidden" id="name" >
<body onLoad="getInfo()">
页面输出,如:
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>nick</td>
<td>score</td>
<td>result</td>
<td>result</td>
</tr>
<tr>
<td><span id="shownick"></span>
</td>
<td><span id="showscore"></span>
</td>
<td><span id="showresult"></span>
</td>
<td><span id="showcontent"></span>
</td>
</tr>
</table>
</body>
</html>
<!--
var xmlhttp;
// 创建XMLHTTPRequest对象
function createXMLHTTPRequest()
{
if(window.ActiveXObject)//②如果当前浏览器为IE
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHTTPRequest)//③如果是其他浏览器
{
xmlhttp = new XMLHTTPRequest();
}
}
function getInfo()
{
var bh =document.getElementById("bh").value;
var name=document.getElementById("name").value;
createXMLHTTPRequest();
if ((bh == null) || (bh == "")) return;
var url = "1.asp?bh=" + escape(bh);
url=url + "&name=" + name;
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = returnInfo;
xmlhttp.send(null);
}
function returnInfo()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var info = xmlhttp.responseText;
// shownr.innerHTML = info;
//返回 info = {"traderates_get_response":{"trade_rates":{"trade_rate":[{"content":"很好!","nick":"平地","result":"good","valid_score":false},{"content":"不错!","nick":"平地","result":"good","valid_score":true}]},"total_results":2}}
showscore.innerHTML = valid_score;
shownick.innerHTML = nick;
showcontent.innerHTML = content;
showresult.innerHTML = result;
}
}
-->
</script>
<input name="bh" type="hidden" id="bh" >
<input name="name" type="hidden" id="name" >
<body onLoad="getInfo()">
页面输出,如:
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>nick</td>
<td>score</td>
<td>result</td>
<td>result</td>
</tr>
<tr>
<td><span id="shownick"></span>
</td>
<td><span id="showscore"></span>
</td>
<td><span id="showresult"></span>
</td>
<td><span id="showcontent"></span>
</td>
</tr>
</table>
</body>
</html>
...全文
相关推荐
Java获取http和https协议返回的json数据
本篇文章主要介绍了Java获取http和https协议返回的json数据 ,本篇文章提供两个方法,帮助各位如何获取http和https返回的数据。有兴趣的可以了解一下。
详解vue渲染从后台获取的json数据
主要介绍了详解vue渲染从后台获取的json数据,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
快速解决处理后台返回json数据格式的问题
今天小编就为大家分享一篇快速解决处理后台返回json数据格式的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
通过URL地址获取远程数据并用json返回
通过URL访问接口,获取数据,并将xml格式转换为json格式输出。
SSM 关于向前台返回json数据问题
SSM 关于向前台返回json数据问题


