• 微软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就可以收了


  • 相关阅读:
    python-socket1
    python-网络编程
    linux-常用指令3
    linux-vim/编辑器
    linux-常用指令2
    linux-常用指令1
    MySQL 练习题
    33 python 并发编程之IO模型
    32 python 并发编程之协程
    31 python下实现并发编程
  • 原文地址:https://www.cnblogs.com/suneryong/p/764105.html
Copyright © 2020-2023  润新知