$.ajax data向后台传递参数失败 contentType: "application/json"
在ajax方法设置中若不添加 contentType: "application/json" 则data可以是对象:
$.ajax({
url: actionurl,
type: "POST",
datType: "JSON",
data: { id: nodeId },
async: false,
success: function () {}
});
若添加 contentType: "application/json" 则data只能是json字符串:
$.ajax({
url: actionurl,
type: "POST",
datType: "JSON",
contentType: "application/json"
data: "{'id': " + nodeId +"}",
async: false,
success: function () {}
});
不添加 contentType: "application/json" 情况下传递多个数据:
{
"id":id[1],
"name":"小明"
}
此时将id和name传到后台。
随机推荐
- 一个操作系统的实现sudo mount -o loop pm.img /mnt/floppy mount point /mnt/floppy does not exist losetup device is busy
部分参考:https://blog.csdn.net/u012323667/article/details/79266623 一. sudo mount -o loop pm.img /mnt/flo ...
- vector最最最基础用法(非原创)
在c++中,vector是一个十分有用的容器,下面对这个容器做一下总结. 1 基本操作 (1)头文件#include<vector>. (2)创建vector对象,vector<in ...
- 使用SQL-Server分区表功能提高数据库的读写性能
首先祝大家新年快乐,身体健康,万事如意. 一般来说一个系统最先出现瓶颈的点很可能是数据库.比如我们的生产系统并发量很高在跑一段时间后,数据库中某些表的数据量会越来越大.海量的数据会严重影响数据库的读写 ...
- Promise nested then execute order All In One
Promise nested then execute order All In One Promise nested then nested Promise not return new Promi ...
- ES6 arrow function vs ES5 function
ES6 arrow function vs ES5 function ES6 arrow function 与 ES5 function 区别 this refs xgqfrms 2012-2020 ...
- js binary search algorithm
js binary search algorithm js 二分查找算法 二分查找, 前置条件 存储在数组中 有序排列 理想条件: 数组是递增排列,数组中的元素互不相同; 重排 & 去重 顺序 ...
- clientHeight & offsetHeight & scrollHeight
clientHeight & offsetHeight & scrollHeight scrollWidth/scrollHeight,offsetWidth/offsetHeight ...
- NGK底层技术如何助力SPC子币VAST高价与安全并行?
NGK近来使用了新的侧链技术推出了新的SPC侧链代币,以及SPC的子币VAST---维萨币. NGK使用去中心化和开源区块链数据分布式协议,不断打造高倍币,力求成为生态建设参与者们所信赖的高倍币孵化器 ...
- efficient c++核心点
整本书写的有点啰嗦,读下核心要点就好. 转载自:https://www.cnblogs.com/opama/p/6446523.html 这是一本讲C++性能优化的书,我差点以为是effective ...
- 发布Jar包到maven中央仓库
什么是maven中央仓库 maven是java世界最流行的构建工具,构建内容囊括了一个java项目的整个生命周期.其中最重要的功能就是依赖管理,maven通过一个类似云的ftp站点统一管理所有java ...