ASP Classic XMLHTTP GET JSON

时间:2014-12-08 21:05:41

标签: json asp-classic xmlhttprequest

我正在尝试使用XMLHTTP GET从URL检索输出:

我直接点击网址时浏览器中的输出如下:

{
 "Titles": {
  "resultCount": 37680,
  "moreResources": true
 }
}

我正在使用的test.asp上的ASP代码是:

<%@language=JScript%>
<%
var objSrvHTTP;
objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.6.0");
objSrvHTTP.open ("GET","http://someipaddress:8080/Publisher/Titles/Paging/0,0,tc?output=json", false);
objSrvHTTP.send ();
Response.ContentType = "application/json";
Response.Write (objSrvHTTP.responseText);
%>

通过点击test.asp在浏览器中显示的结果是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>something</title>
</head>

<body>
{
"Titles": {
"resultCount": 37698,
"moreResources": true
}
}
</body>
</html>

我希望只返回返回的body标签之间的数据,或者更好的只是“resultCount”的值。任何帮助将非常感激。

1 个答案:

答案 0 :(得分:0)

您需要删除HTML标记,在阅读JSON数据时,它应该只是请求响应中的有效JSON

相关问题