zoukankan      html  css  js  c++  java
  • ajax监听事件

    1.创建ajax的核心对象
    var xhr = null;
    if (window.XMLHttpRequest){
    xhr = new XMLHttpRequest();
    }else{
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    console.log('就绪状态' + xhr.readyState);
    console.log('状态码' + xhr.status);
    console.log('响应文本' + xhr.responseText);
    console.log(" ")

    // 2.绑定监听事件
    xhr.onreadystatechange = function(){
    console.log('就绪状态' + xhr.readyState);
    console.log('状态码' + xhr.status);
    console.log('响应文本' + xhr.responseText);
    console.log(' ')
    }
    // 3.创建请求的消息,连接服务器 readyState 0 => 1
    xhr.open('GET','02.php',true);
    // 1.请求的方式 POST/GET
    // 2.请求的地址
    // 3.[同步||异步] true表示异步,默认

    // 4.发送请求
    xhr.send(null)
    // get请求的参数一般放在url后面,
    // post请求参数就写在send中

    // status状态码
    // 1xx 信息类错误
    // 2xx 成功 200
    // 3xx 重定向 304
    // 4xx 客户端错误 404未找到
    // 5xx 服务端错误 506

  • 相关阅读:
    HDU 1097
    HDU 1045
    HDU 1039 -Easier Done Than Said?
    HDU 1038
    HDU 1037 - Keep on Truckin'
    HDU 1036 - Average is not Fast Enough!
    hdu 1701 ACMer
    hdu 1711 Number Sequence(kmp)
    hdu 2087 剪花布条
    字符串匹配-KMP算法学习笔记
  • 原文地址:https://www.cnblogs.com/6909ye/p/9766614.html
Copyright © 2011-2022 走看看