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){}
})
相关推荐
阿pin11 小时前
Android随笔-kotlin withContext
android·kotlin·withcontext
树码小子11 小时前
开启 IDEA 中的断言功能
android·java·intellij-idea
Kslient11 小时前
HeaderBehavior
android
Android-Flutter13 小时前
android 动画详解
android·kotlin
小孔龙18 小时前
GraphicBuffer 跨进程共享
android
行业研究员18 小时前
Android内置GPS与腾讯地图定位技术对比分析
android·android定位·腾讯地图定位
Android-Flutter19 小时前
android WMS 详解(二)
android·kotlin
游戏开发爱好者820 小时前
App Store 上传 IPA 自动化,.p8 密钥认证与 CI/CD 接入实战
android·运维·ci/cd·小程序·uni-app·自动化·iphone
游戏开发爱好者821 小时前
iOS 推送怎么配置,APNs 推送证书、设备库与群发
android·ios·小程序·https·uni-app·iphone·webview
阿pin21 小时前
Android随笔-kotlin 高阶函数
android·kotlin·高阶函数