jQuery系列---【jQuery中ajax封装】

jQuery中ajax封装

$.ajax({
            url: '', // 请求地址
            cache: '', // 是否缓存
            type: '', // 请求类型 get/post 默认get
            timeout: '', // 请求超时时间, 单位是毫秒
            data: '', // 请求的参数
            dataType: '', // 返回数据的格式 xml html text script json jsonp
            success: function (res) {}, // 成功的回调
            error: function (err) {}, // 失败的回调
            complete: function () {} // 完成的回调
        });

//调用
  $.ajax({
            url: 'bendi.txt',
            type: 'get',
            success: function (res) {
                console.log(res);
            }
        });

注意:要先引入jQuery文件

原文地址:https://www.cnblogs.com/chenhaiyun/p/14651692.html