AJAX请求头Content-type
作者:互联网
发送json格式数据
xhr.setRequestHeader("Content-type","application/json; charset=utf-8");
发送表单数据
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
发送纯文本
不指定Content-type时,此是默认值值
xhr.setRequestHeader("Content-type", "text/plain; charset=utf-8");
发送html文本
xhr.setRequestHeader("Content-type", "text/html; charset=utf-8");
编码可带可不带
// 不带字符编码写法 xhr.setRequestHeader("Content-type", "application/json");
值对大小写不敏感
xhr.setRequestHeader("Content-type","Application/JSON; charset=utf-8");
标签:utf,charset,setRequestHeader,Content,xhr,AJAX,type 来源: https://blog.51cto.com/u_14302606/2813419