使用ajax无刷新技术
ajax.htm
<script> function f(){ var req =new ActiveXObject("Microsoft.XMLHTTP"); req.open("GET","ajax.asp?t1="+t1.value, true); req.onreadystatechange = function(){ if (req.readyState == 4) { if (req.status == 200) { msg.innerText = req.responseXML.documentElement.tagName; } } } req.send(null); }</script>
1:显示”OK”; 其他字符:显示”Error”
<input id="t1" /> <input type="button" onclick="f();" />
ajax.asp
<!--r> Response.ContentType="text/xml" if request.querystring("t1")="1" then response.write("<ok/>") else response.write("<error/>") end if -->
传统asp无刷新技术
old.htm
<script> function f(){ document.getElementById("o").src="old.asp?t1=" mce_src="old.asp?t1="+t1.value }</script>
1:显示”OK”; 其他字符:显示”Error”
<input name="1" id="t1" /> <input type="button" onclick="f();" /><iframe src="old.asp" style="display: none" id="o"></iframe>
old.asp
<!--r> if request.querystring="" then response.end end if if request.querystring("t1")="1" then ss="OK" --> <script> parent.msg.innerText="<%=ss%>"</script>关注微信公众号,手机阅读更方便: 程序员的阅微草堂

莿鸟栖草堂 由 CFC4N 创作,采用 知识共享 署名-非商业性使用-相同方式共享(3.0未本地化版本)许可协议进行许可。基于http://www.cnxct.com上的作品创作。转载请注明转自:AJAX技术 vs 传统的ASP无刷新技术