• 微软ajax 的写法


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
     <head>
      <title></title>

      <script language="javascript">
    function makeRequest(url)
    {
    if(window.XMLHttpRequest)
    { request = new XMLHttpRequest();}
    else
    if(window.ActiveXObject)
    { request = new ActiveXObject("MSXML2.XMLHTTP.5.0");}
    request.onreadystatechange = onResponse;
    request.open("POST", url, false);
    request.setRequestHeader('content-type','application/x-www-form-urlencoded');
    request.send("a=1&b=2");

    }


    function onResponse()
    {
    var obj=request;
    if(obj.readyState == 0)
    { document.getElementById('copy').innerHTML = "Sending Request...";}
    if(obj.readyState == 1)
    { document.getElementById('copy').innerHTML = "Loading Response...";}
    if(obj.readyState == 2)
    { document.getElementById('copy').innerHTML = "Response Loaded...";}
    if(obj.readyState == 3)
    { document.getElementById('copy').innerHTML = "Response Ready...";}
    if(obj.readyState == 4){
    if(obj.status == 200)
    {
    var response = obj.responseText;
    document.getElementById('copy').innerHTML = response;
    }
    else if(obj.status == 404)
    {
    // 添加一个定制消息或把用户重定向到另外一个页面
    document.getElementById('copy').innerHTML = "File not found";
    }
    else
    {document.getElementById('copy').innerHTML = "There was a problem retrieving the XML."; }
    }


    }
      </script>
     </head>
     <body onload="makeRequest('WebForm2.aspx');">
      <div id="copy"></div>
     </body>
    </html>

    注意这里是用post的方法,一定要写post头的,以指明post文档类型,用get方法是a.aspx?id=1&jj=4这样用的
    目标文件用request就可以收了


  • 相关阅读:
    数论学习之乘法逆元
    数论学习之扩展欧几里得
    数论学习之费马与欧拉
    一次函数
    东南西北
    接水问题
    脱水缩合
    背单词
    单词接龙
    字符串,字符数组
  • 原文地址:https://www.cnblogs.com/suneryong/p/764105.html
Copyright © 2020-2023  润新知