AJAX技术 vs 传统的ASP无刷新技术
使用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>