zoukankan      html  css  js  c++  java
  • ajax原理和XmlHttpRequest对象

    function CreateXmlHttp() {

    //非IE浏览器创建XmlHttpRequest对象

    if (window.XmlHttpRequest) {

    xmlhttp = new XmlHttpRequest();

    }

    //IE浏览器创建XmlHttpRequest对象

    if (window.ActiveXObject) {

    try {

    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    }

    catch (e) {

    try {

    xmlhttp = new ActiveXObject("msxml2.XMLHTTP");

    }

    catch (ex) { }

    }

    }

    }

    function Ustbwuyi() {

    var data = document.getElementById("username").value;

    CreateXmlHttp();

    if (!xmlhttp) {

    alert("创建xmlhttp对象异常!");

    return false;

    }

    xmlhttp.open("POST", url, false);

    xmlhttp.onreadystatechange = function () {

    if (xmlhttp.readyState == 4) {

    document.getElementById("user1").innerHTML = "数据正在加载...";

    if (xmlhttp.status == 200) {

    document.write(xmlhttp.responseText);

    }

    }

    }

    xmlhttp.send();

    }

    有些事现在不做,一辈子都不会做了
  • 相关阅读:
    记一次centos 服务器中毒事件
    heatmap
    this
    购物车
    带标签的无缝轮播
    无缝轮播
    图片滚动百分百宽度
    选择排序
    冒泡排序
    tab标签页
  • 原文地址:https://www.cnblogs.com/mengkai/p/6187680.html
Copyright © 2011-2022 走看看