惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
U
Unit 42
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
博客园 - 司徒正美
Vercel News
Vercel News
I
InfoQ
GbyAI
GbyAI
C
Check Point Blog
B
Blog RSS Feed
Martin Fowler
Martin Fowler
B
Blog
MyScale Blog
MyScale Blog
腾讯CDC
博客园 - Franky
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)

博客园 - James·wang

【转发】怎么解决Sql Server 2008数据库Windows账户和sa账户被禁用以后无法登录的问题 win10企业版ltsc激活 全球IP地址段 C#中可为NULL(空)的时间值的判断或赋值问题 解决Windows不能上https://github.com/网站的问题 更改Windows Server 远程桌面端口3386 jqGrid冻结某一列的注意事项 js 获取可视界面的高度或宽度 激活Windows10 文件下画线与文字有一定的间隔css Windows Server 任务计划执行bat脚本,无法正常自动执行的解决方案 js自动倒计时代码,倒计时完毕时自动停止循环 win11跳过微软账号登录方法 本地Windows10怎样配置免安装版本MySQL? Windows Server2022怎么做文件共享? Windows Server 使用ICACLS在命令行给文件赋予权限 去除两个JSON对象集合中的重复数据 jquery使用$.grep删除数组中的某个值 C#在集合中使用lamda更改某字段的值并返回新的集合 [转发]jquery .filter()过滤器
前端Ajax中请求数据中body和query传参的方法
James·wang · 2024-07-04 · via 博客园 - James·wang

一、post请求可以传body和query两种形式的参数:

【body传参】:
$.ajax({
   type : "POST",
   url : "xxxxxxxxxxxxxx",
   data : {
    ids: tempID
    }
   ...
  })
【body传参,当要求传JSON字符串格式的参数时】:
$.ajax({
   type : "POST",
   url : "xxxxxxxxxxxxxxxx",
   dataType : "json",
   data : JSON.stringify({ids: tempID}),
   contentType:"application/json;charset=utf-8",
    ...
  })

二、当query传参时:

$.ajax({
   type : "POST",
   url : "xxxxxxxxxxxxxx",
   params: params // params就是query参数,params的值只能是一个字符串多个参数要使用&连接,不能传递对象类型的参数,如果参数中涉及到了传递对象,就要选择body传参
/ //比如:?oginType=a&target1=b&target2=c&validateCode=d&userType=e&rememberMe=f
... })