请教JS调用一个asp动态页面的方法!!比如:优酷 的评论区!!他实现的原理什么?
谢谢!!

解决方案 »

  1.   

    AJAX
    <script language="javascript">
    //创建xmlHttp对象
    var xmlHttp=false;
    function createXMLHttpRequest(){
        xmlHttp=false;
    try{
        xmlHttp = new XMLHttpRequest();
        }
    catch(trymicrosoft)
        {
            try{
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(othermicrosoft){
                try{
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(failed){
                    return false;
                }
            }
        }
       if (!xmlHttp){
         alert("错误!无法创建XMLHttpRequest对象!可能是您的浏览器不支持ajax.");
         //return false;
       }
    }
    //
    function checkusername(){
        var a=document.getElementById('a').value;
        var b=document.getElementById('b').value;
        var c=document.getElementById('c').value;
        createXMLHttpRequest();
        xmlHttp.open("get","check.asp?a="+a+"&b="+b+"&c="+c+"",true);//访问某个页面    xmlHttp.onreadystatechange=function(){
            if(xmlHttp.readyState==4&&xmlHttp.status==200){
                if(xmlHttp.responseText.toLowerCase()=='true')//如果该页面输出的是true
                    alert("此用户名已被占用,请更换...");
                else
                    alert("此用户名可以注册...");
            }
        }
        xmlHttp.send(null);
        }</script>
    <form id="form1" name="form1" method="post" action="">
      <input type="text" name="a" id="a" />
      <input type="text" name="b" id="b" />
      <input type="text" name="c" id="c" onblur="checkusername()" />
    </form>
    check.asp页面代码
    <%
    a = request.QueryString("a")
    b = request.QueryString("b")
    c= request.QueryString("c")if a = "a" and b = "b" and c = "c" then
    response.Write "true"
    else
    response.Write "false"
    end if
    %>
      

  2.   

    <script src="showmsg.asp"></script>
    showmsg.asp:
    <% 
    response.Write "document.write('流言信息')" 
    %>