jQuery ajax请求

$(function () {
    $.ajax({
        //请求的地址
        url: "http://www.hefeixyh.com/informations/getAllInFormations",
        //请求参数
        data: {id: 1},
        //禁止浏览器缓存信息
        cache: false,
        //请求方式
        type: "GET",
        //是否异步
        async: false,
        //在信息发送前执行的操
        beforeSend: function () {
            alert("信息发送前执行的操");
        },
        //请求成功的回调函数:res就是回调的对象
        success: function (res) {
            alert("请求成功!");
            let arr = JSON.parse(res);
            console.log(arr);
            for (let i = 0; i < arr.length; i++) {
                console.log(arr[i]);
            }
        },
        //请求成功的回调函数:res就是回调的对象
        error: function f(e) {
            alert("请求失败!");
            console.log(e);
        }
    });
});

猜你喜欢

转载自blog.csdn.net/qq_44472722/article/details/89147036