jQuery封装的ajax操作

jQuery中ajax请求有三种操作方式$.get()  $.post()  $.ajax()

get和post(是对$.ajax的封装)

//不传递数据
$.get("./16.php",function(msg){
        alert(msg);
});

//给服务器传递数据
$.get("./16.php",{name:‘tom‘,age:23},function(msg){
        alert(msg);
});

//用法与get方法类似
$.post("./16.php",{},function(){});

 

$.ajax是jQuery底层的ajax方法

$.ajax({
    url:"./16.php",
    data:"name=tom&addr=beijing&age=23",
    dataType:‘text‘,
    async:false,
    type:‘post‘,
    success:function(msg){
        //ajax请求成功后要执行这个的代码
        alert(msg);
    }
});

  

jQuery封装的ajax操作,布布扣,bubuko.com

jQuery封装的ajax操作

上一篇:css selection改变文字反选的背景颜色


下一篇:CentOS-7.5 搭建 MySQL 主从复制