首页 > Web开发 > 详细

Ajax与Layui

时间:2018-07-21 16:25:38      阅读:200      评论:0      收藏:0      [点我收藏+]

ajax:请求  响应

js
  //创建ajax对象
  var xhr=new XMLHttpRequest();
  //监听ajax状态
 xhr.onreadystatechange=function(){
  if(xhr.readyState == 4){
   console.log(xhr.responseText);
  }
 }
  //发起请求
  xhr.open(‘get‘,‘index.html?name=zhangsan&age=12‘);
//  xhr.open(‘post‘,‘index.html?name=zhangsan&age=12‘);
  //传数据
  xhr.send(null);

jQuery
   $.ajax({
    async:true, //同步和异步   默认是的同步    同一个时间点允许执行多个过程
    url:"fwq.php",//提交地址
    data:{name:"zhangsan",age:12},//提交数据
       type:‘post‘,//默认get
    dataType:‘text‘,//默认值text
    success:function(data){
           
       }
   });
 

Ajax与Layui

原文:https://www.cnblogs.com/2734156755z/p/9242355.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!