将javascript var传递给经典的asp函数作为参数

时间:2015-04-06 16:59:56

标签: javascript ajax asp-classic

我有一个页面,通过ajax调用从2个不同的页面中获取2个表(不使用JQuery)

我想通过搜索返回的内部html响应来查看每个页面返回的行数。

然后将记录计数设置为变量(在asp中)(通过使用正则表达式计算tr条目来产生xmlhttp请求的结果)

因为我需要执行if-condition并根据记录计数处理问题

这里是我需要的简化样本:(不工作)

<%
dim hi
hi ="hi there"

function hiFunc (val)
hiFunc = val
end function
%>
<script type="text/javascript">
var xmlhttp ;
function test()
{

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.open("GET", "somepage.asp?q=blablabla", true);
xmlhttp.send();

xmlhttp.onreadystatechange = 
function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
{

var hi ="<%=hiFunc(xmlhttp.responseText)%>";
alert("test: \n<%=hi%>");
}
       }           

}

这可行吗?

感谢您的合作。

0 个答案:

没有答案