AJAX-POST设置请求体

Posted 小姚同学要继续加油呀

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AJAX-POST设置请求体相关的知识,希望对你有一定的参考价值。

AJAX发送请求

//1.创建对象
const xhr = new XMLHttpRequest();
//2.初始化 设置类型与 URL
xhr.open('POST','http://127.0.0.1:8000/server');
//3.发送
xhr.send();
xhr.onreadystatechange = function()
	//判断
	.....
	//ex if(xhr.readyState === 4)
			//if(xhr.status>=200 && xhr.status <300) .....

设置请求体

要在xhrObj.send()中设置要传的参数

xhr.send('a=100&b==200&c=300')

以上是关于AJAX-POST设置请求体的主要内容,如果未能解决你的问题,请参考以下文章