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);
    }
});
相关推荐
砌玉成璧7 小时前
Flask+HTML+Jquery 文件上传下载
flask·html·jquery
北冥SP15 小时前
OkHttp连接池
网络·okhttp
zhougl99616 小时前
OkHttp用法-Java调用http服务
java·http·okhttp
巴巴_羊1 天前
AJAX 使用 和 HTTP
前端·http·ajax
sunxunyong2 天前
yarn任务筛选spark任务,判断内存/CPU使用超过限制任务
javascript·ajax·spark
淡笑沐白2 天前
AJAX技术全解析:从基础到最佳实践
前端·ajax
Go_going_2 天前
ajax,Promise 和 fetch
javascript·ajax·okhttp
羽球知道2 天前
在Spark搭建YARN
前端·javascript·ajax
mini榴莲炸弹2 天前
什么是SparkONYarn模式?
前端·javascript·ajax
能来帮帮蒟蒻吗2 天前
VUE3 -综合实践(Mock+Axios+ElementPlus)
前端·javascript·vue.js·笔记·学习·ajax·typescript