zoukankan      html  css  js  c++  java
  • 什么是ajax,以及使用

    1.Ajax技术合成 异步的JavaScript and xml css 资源

    2.异步请求和局部刷新。
    同步请求:等待第一个请求响应数据回发回来后,再发送第二次请求。
    $.ajax(是否异步)

    3.Ajax怎么运作? 一把枪 谁?js驱动这把枪
    原生态Ajax核心对象:
    判定当前的浏览器引擎有没有哪个对象? 能力检查 (情况1:IE 和非IE chrome和FireFox)
    1.构建核心对象 XmlHttpRequest xhr;


    2.设置他的属性和方法
    xhr.open("post","/FirstServlet",true);
    xhr.onreadystatechange=funtion(){
    if(xhr.readyState==4&&xhr.status==200){
    }

    };

    你要想发送Post请求,必须得有Content-Type
    xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xhr.send(get:null/post:data);

    4.使用jQuery实现Ajax
    function newAjax() {
    $.ajax({
    url:"/FirstServlet",
    type:"POST",
    data:{"uname":$("[name=uname]").val()},
    async:true,
    success:function (data) {
    $("#msg").html(data);
    }
    });
    }

    传统Web与Ajax的区别:

  • 相关阅读:
    A. Difference Row
    B. Fixed Points
    命运
    Climbing Worm
    大学感想
    Constructing Roads
    lintcode605- Sequence Reconstruction- medium- airbnb google
    lintcode616- Course Schedule II- medium
    lintcode615- Course Schedule- medium
    lintcode127- Topological Sorting- medium
  • 原文地址:https://www.cnblogs.com/hsa521/p/7678464.html
Copyright © 2011-2022 走看看