JQ ajax 请求

相比 js 来说JQ为我们封装了 $.ajax直接用就行了,既简单又方便,减少了代码量。

    //jq ajax 请求
    $.ajax({
        type: "GET"/"POST",
        url: "目标文件.php",
        data: {
           所要传到后端的数据
        },
        async:true,
        dataType: "json",
        sucess:responsRes,
        error:function (err) {
            console.log(err);
        }
    });
    function responsRes(abc){
        console.log(abc);
    }
	$.ajax({
				url: 'http://www.xiaoma.com/channel_ajax.php',
				type: 'post',
				data: {},
				dataType: 'json'
			}).then(function(res) {
				console.log(res,444);
				//把从json获取的数据赋值给数组
			}).fail(function() {
				console.log('失败');
			})
原文地址:https://www.cnblogs.com/heson/p/10014470.html