jquery中ajax总结

在ajax请求接口的时候,常用到以下参数,在这里记录下

contentType用于告诉服务器请求的数据类型,常见的有

text/html:HTML网页

text/plain:纯文本

application/json:JSON格式

application/xml:XML格式

image/gif:GIF图片

image/jpeg:JPEG图片

audio/mpeg:音频MP3

video/mpeg:视频MPEG

Content-Type描述了消息体语言字符编码和内容格式,每个Content-Type都包含了多个参数,他们用";"分割

javascript 复制代码
let params={
        ticket:'12312313',
        moveLength:'45',
        phone:'13821569856',
 };
$.ajax({
        url:'/member/register/checkCodeImg',
        data:JSON.stringify(params),//将json对象转成字符串传输
        type:'post',
        dataType:'json',
        contentType: 'application/json;charset=UTF-8',
        async:false,//是否异步
        success:function(data){},
        error:function(data){}
})
相关推荐
zhangphil13 小时前
Android Bitmap.Config.HARDWARE属性产生的来源和控制权
android
小陈的进阶之路13 小时前
Python系列课(11)——PySpark
开发语言·python·ajax
YF021113 小时前
深度解构Android OkDownload断点续传
android·数据库·okhttp
Co_Hui13 小时前
Android: Service基本使用
android
恋猫de小郭14 小时前
Android Studio 放着没怎么用,怎么也会越来越卡?
android·前端·flutter
Kapaseker14 小时前
Compose 动画 — 显隐的艺术
android·kotlin
黄林晴14 小时前
Android官方发布 AppFunctions,让系统AI直接调用你的APP
android·agent
橙淮14 小时前
jQuery性能优化终极指南
javascript·jquery
2501_9159090615 小时前
完整指南:如何将iOS应用上架到App Store
android·ios·小程序·https·uni-app·iphone·webview
赏金术士17 小时前
Retrofit + Kotlin 协程(Android 实战教程)
android·kotlin·retrofit