zoukankan      html  css  js  c++  java
  • Microsoft 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就可以收了


  • 相关阅读:
    JAVA基础知识之JVM-——反射和泛型
    JAVA基础知识之JVM-——动态代理(AOP)
    顶层const和底层const
    C#正则分组实例
    jQuery延迟加载(懒加载)插件 – jquery.lazyload.js
    vs2015打开cshtml文件失败的解决方法
    Postman的使用
    webapi中的Route的标签的命名参数name的使用
    webapi中Route标签定义可选参数
    webapi中的自定义路由约束
  • 原文地址:https://www.cnblogs.com/suneryong/p/718522.html
Copyright © 2011-2022 走看看