• AJAX


    # What

    AJAX = Asynchronous JavaScript and XML(异步的 JavaScript 和 XML)。

    AJAX 不是新的编程语言,而是一种使用现有标准的新方法。

    # Why

    AJAX 是与服务器交换数据并更新部分网页的艺术,在不重新加载整个页面的情况下。

    # How

    Example:

    var xmlhttp;
    function loadXMLDoc(url)
    {
    xmlhttp=null;
    if (window.XMLHttpRequest)
      {// code for Firefox, Opera, IE7, etc.
      xmlhttp=new XMLHttpRequest();
      }
    else if (window.ActiveXObject)
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    if (xmlhttp!=null)
      {
      xmlhttp.onreadystatechange=state_Change;
      xmlhttp.open("GET",url,true);
      xmlhttp.send(null);
      }
    else
      {
      alert("Your browser does not support XMLHTTP.");
      }
    }
    
    function state_Change()
    {
    if (xmlhttp.readyState==4)
      {// 4 = "loaded"
      if (xmlhttp.status==200)
        {// 200 = "OK"
        document.getElementById('T1').innerHTML=xmlhttp.responseText;
        }
      else
        {
        alert("Problem retrieving data:" + xmlhttp.statusText);
        }
      }
    }

    POST:

    xmlhttp.open("POST","ajax_test.asp",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("fname=Bill&lname=Gates");
  • 相关阅读:
    甲级1008 Elevator
    甲级1004 Counting Leaves
    甲级1007 Maximum Subsequence Sum
    甲级1006 Sign In and Sign Out
    甲级1005 Spell It Right
    甲级1003 Emergency
    甲级1002. A+B for Polynomials
    ..
    使用git版本管理打包增量更新包
    c++实现互斥锁
  • 原文地址:https://www.cnblogs.com/Piers/p/6549446.html
Copyright © 2020-2023  润新知