87,907
社区成员
发帖
与我相关
我的任务
分享
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
/**主要采用切分字符串获取相应数据*/
var xmlhttp;
function loadXMLDoc()
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Opera, etc.
if(navigator.userAgent.indexOf("MSIE")>0) {
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new XMLHttpRequest();
try
{
if(window.netscape){
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
}
catch (exception)
{
alert(exception);
}
}
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","https://api.weibo.com/2/users/counts.json?access_token=2.00fLf2WF0zMudC23caca79da0gOzF6&uids=1959107744",false);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "OK"
var strRetn =xmlhttp.responseText;
var str=strRetn.substring(1,strRetn.length-1);
var obj=eval('(' + str + ')');
//获取对应数据进行下面的操作
//alert(obj.id);
alert(obj.followers_count);
}
else
{
alert("Problem retrieving XML data:" + xmlhttp.responseText);
}
}
}
loadXMLDoc();
</script>
</body>
</html>