具体内容如下所示:

$.ajax({

type: httpmethod,

cache:false,

async:false,

contenttype: "application/json; charset=utf-8",

datatype: "json",//返回值类型

url: path+url,

data:jsondata,

success: function(data){

var resultdata = '返回码='+data.status+',响应结果='+data.message+',耗时='+data.tcost;

layer.msg(resultdata,{icon: 1});

},

error : function(xhr, ts, et) {

layer.msg('服务调用失败!', {icon: 2});

}

});

区分:

contenttype: 发送信息至服务器时内容编码类型,简单说告诉服务器请求类型的数据

默认值: "application/x-www-form-urlencoded"

datatype:告诉服务器,我要想什么类型的数据,除了常见的json、xml,还可以指定 html、jsonp、script或者text

不使用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 () {}

});

总结

以上所述是小编给大家介绍的$.ajax中contenttype: “application/json” 的用法,希望对大家有所帮助

ajax_contenttype,$.ajax中contentType: “application/json” 的用法详解相关推荐

  1. python request.post 字典参数以json_Python requests.post方法中data与json参数区别详解

    在通过requests.post()进行POST请求时,传入报文的参数有两个,一个是data,一个是json. data与json既可以是str类型,也可以是dict类型. 区别: 1.不管json是 ...

  2. python post json参数,Python requests.post方法中data与json参数区别详解

    在通过requests.post()进行POST请求时,传入报文的参数有两个,一个是data,一个是json. data与json既可以是str类型,也可以是dict类型. 区别: 1.不管json是 ...

  3. python的raw_ input是什么意思-对python中raw_input()和input()的用法详解

    最近用到raw_input()和input()来实现即时输入,就顺便找了些资料来看,加上自己所用到的一些内容,整理如下: 1.raw_input() raw_input([prompt]) -> ...

  4. python中str和input_对python中raw_input()和input()的用法详解

    最近用到raw_input()和input()来实现即时输入,就顺便找了些资料来看,加上自己所用到的一些内容,整理如下: 1.raw_input() raw_input([prompt]) -> ...

  5. js数组中foEach和map的用法详解 jq中的$.each和$.map

    数组中foEach和map的用法详解 相同点: 1.都是循环遍历数组(仅仅是数组)中的每一项. 2.forEach() 和 map() 里面每一次执行匿名函数都支持3个参数:数组中的当前项value, ...

  6. 教程-Delphi中Spcomm使用属性及用法详解

    Delphi中Spcomm使用属性及用法详解 Delphi是一种具有 功能强大.简便易用和代码执行速度快等优点的可视化快速应用开发工具,它在构架企业信息系统方面发挥着越来越重要的作用,许多程序员愿意选 ...

  7. python3 isinstance用法_对python中assert、isinstance的用法详解

    1. assert 函数说明: Assert statements are a convenient way to insert debugging assertions into a program ...

  8. python中tile的用法_python3中numpy函数tile的用法详解

    tile函数位于python模块 numpy.lib.shape_base中,他的功能是重复某个数组.比如tile(A,n),功能是将数组A重复n次,构成一个新的数组,我们还是使用具体的例子来说明问题 ...

  9. python中mat函数_Python中flatten( )函数及函数用法详解

    flatten()函数用法 flatten是numpy.ndarray.flatten的一个函数,即返回一个一维数组. flatten只能适用于numpy对象,即array或者mat,普通的list列 ...

最新文章

  1. swift Swauth install
  2. 算法导论系列:分治算法
  3. POJ 2513 Colored Sticks
  4. Week2 Teamework from Z.XML 软件分析与用户需求调查(三)必应助手体验评测
  5. Python: 常用的软件包
  6. Java中的JPA是什么意思?
  7. ACM顽固错误之WA——常见掉坑点
  8. SkeyeVSS综合安防监控Onvif、RTSP、GB28181视频云解决方案之服务器系统硬件资源管理
  9. GradientDrawable 渐变背景使用
  10. 从hr口中了解react的状态管理库(mobx, recoil), 立马过来学习之mobx
  11. 【win7安装composer错误】:The quot;https://getcomposer.org/download/1.6.2/composer.phar.sigquot; file cou
  12. page_to_pfn 、virt_to_page、 virt_to_phys、page、页帧pfn、内核虚拟地址、物理内存地址linux内核源码详解
  13. excel筛选后复制粘贴
  14. Dart factory 快速理解
  15. Dump文件分析 - PDB强制匹配流程
  16. 级联选择器el-cascader处理复杂数据(四层、五层数据),回显部门以及部门下的人员
  17. livecd linux 原理,将现有Ubuntu系统做成LiveCD
  18. Postman+Postman interceptor使用
  19. 2021年东莞东华中学高考成绩查询,东莞中学排名前十名,2021年东莞中学排名一览表...
  20. 长期更新收藏的函数——那些年我们跪在键盘上欣赏过的函数

热门文章

  1. excel格子颜色_在Excel中创建格子图案
  2. Jenkins 中文设置
  3. oracle rowid 优先级,Oracle中rowid的用法(全面)
  4. GNSS监测站在滑坡和地质灾害中的应用
  5. 蚂蚁森林版本更新,大家喜欢吗
  6. “讨好型人格”在社会中为什么总是吃亏
  7. 按钮动作监听器和鼠标监听器的同时实现,在画图板上画出三角形,射线,曲笔,谢尔宾斯基三角形,谢尔宾斯基地毯Random类的实现,数组的实现,Thread.sleep的实现
  8. 关于谢尔宾斯基地毯的讲解
  9. 实至名归 | 天威诚信入选《中国网络安全企业100强》
  10. sudo 命令无法使用