jq的ajax请求写法

$.post写法

$.post('url',{data:''}, function (result) {
    console.log(result);
}, "json");

 $.ajax写法

$.ajax({
    url:"http://www.microsoft.com",    //请求的url地址
    dataType:"json",   //返回格式为json
    async:true,//请求是否异步,默认为异步,这也是ajax重要特性
    data:{"id":"value"},    //参数值
    type:"POST",   //请求方式
    beforeSend:function(){
        //请求前的处理
    },
    success:function(req){
        //请求成功时处理
    },
    complete:function(){
        //请求完成的处理
    },
    error:function(){
        //请求出错处理
    }
});

参考:https://blog.csdn.net/u011558902/article/details/39934419

      https://www.cnblogs.com/masonlu/p/10797127.html

原文地址:https://www.cnblogs.com/fangxinliu/p/13365169.html