$.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传到后台。
随机推荐
- python = 赋值顺序 && C++ side effect
title: python = 赋值顺序 && C++ side effect date: 2020-03-17 15:00:00 categories: [python][c++] ...
- select函数详细用法解析
1.表头文件 #include #include #include 2.函数原型 int select(int n,fd_set * readfds,fd_set * writefds,fd_set ...
- iView 的后台管理系统简易模板 iview-admin-simple
iview-admin-simple 是基于 iView 官方模板iView admin整理出来的一套后台集成解决方案.iview-admin-simple删除了iView admin的大部分功能,只 ...
- 如何用 js 实现一个 class 类函数
如何用 js 实现一个 class 类函数 原理 实现方式 总结 refs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere ...
- node.js & Unbuntu Linux & nvm & npm
node.js & Unbuntu Linux & nvm & npm https://websiteforstudents.com/install-the-latest-no ...
- Taro Next
Taro Next Taro 2.0 https://aotu.io/notes/2020/02/03/taro-next-alpha/index.html Taro Next 的迁移指南 https ...
- PWA & bug
PWA bug https://developer.mozilla.org/zh-CN/docs/Web/Progressive_web_apps https://learning.xgqfrms.x ...
- Baccarat中挖矿、兑换和做市的三角关系是什么?
NGK在这波DeFi潮中,推出了Baccarat,为用户带来了流动性挖矿收益,今天笔者就讲一讲Baccarat中挖矿.兑换和做市的关系. 兑换和做市是什么关系呢?众所周知,换币者,是用一种货币去换另一 ...
- 01_MySQL从下载—>安装—>到快速上手
一.MySQL下载 二.MySQL安装 三.MySQL几条简单命令快速上手(增删改查) 一.MySQL下载与安装 下载地址:https://dev.mysql.com/downloads/mysql/ ...
- Python数据结构与算法_反转字符串(08)
编写一个函数,其作用是将输入的字符串反转过来.输入字符串以字符数组 char[] 的形式给出. 不要给另外的数组分配额外的空间,你必须原地修改输入数组.使用 O(1) 的额外空间解决这一问题. 你可以 ...