jQuery实现ajax语法,post请求发送数组对象(jquery)

$.ajax()代码模板

jQuery实现ajax语法为:$.ajax({}),其中{}为对象,对象里面的key键是固定的,比如:
1、type: 表示请求方式,一般为post或get
2、url表示请求的地址
3、contentType表示发送信息至服务器时内容编码类型
4、data表示发送到服务器的数据
5、dataType表示预期服务器返回数据的类型如:text,json,xml等等类型
6、success表示请求成功后的回调函数
7、error自动判断 (xml 或 html)。请求失败时调用此函数,等等

对象中包含数组对象

js 复制代码
let htLockRelationCard = {
    userList: userList,
    roomId: roomId,
    cardNumber: cardNum
};
$.ajax({
    url: `smartLockRoomRelationCard/cardDelivery`,
    type: "POST",
    contentType: "application/json",
    data: JSON.stringify(htLockRelationCard),
    dataType: "json",
    success: function (res) {
        console.log(res);
    }
});

数组对象

js 复制代码
$.ajax({
    url: `smartLockRoomRelationCard/cardDelivery`,
    type: "POST",
    contentType: "application/json",
    data: JSON.stringify(userList),
    dataType: "json",
    success: function (res) {
        console.log(res);
    }
});
相关推荐
止水编程 water_proof1 天前
JQuery 基础
前端·javascript·jquery
chilavert3182 天前
技术演进中的开发沉思-278 AJax :Rich Text(上)
前端·javascript·ajax
chilavert3182 天前
技术演进中的开发沉思-279 AJax :Rich Text Editor(下)
前端·javascript·ajax
搬砖的阿wei2 天前
JavaScript 请求数据的四种方法:Ajax、jQuery 、Fetch和 Axios
javascript·ajax·axios·jquery
2501_944441753 天前
Flutter&OpenHarmony商城App下拉刷新组件开发
javascript·flutter·ajax
qq_406176143 天前
JavaScript的同步与异步
前端·网络·tcp/ip·ajax·okhttp
chilavert3183 天前
技术演进中的开发沉思-277 AJax :Calendar
前端·javascript·microsoft·ajax
chilavert3183 天前
技术演进中的开发沉思-276 AJax : Menu
javascript·ajax·交互
假装我不帅3 天前
jquery.nicescroll使用
前端·javascript·jquery
chilavert3184 天前
技术演进中的开发沉思-274 AJax :Button
前端·javascript·ajax·交互