ajax规范写法

$.ajax({
    url: "http://1.1.1.1/api/v2/user/inviters", //接口
    type: "post", //GET或POST
    data: JSON.stringify({}), //数据
    headers: {
        'Content-Type': 'application/json'
    },
    //dataType: 'json',    //返回的数据格式:json/xml/html/script/jsonp/text
    success: function(msg) {
        if (msg.data && msg.data.inviters) {
            addFimg(msg.data.inviters);
        }

    }, //回调成功方法
    error: function(xhr, textStatus) {
        console.log(xhr);
        console.log(textStatus)
    }
});
原文地址:https://www.cnblogs.com/phpfensi/p/7298561.html