JavaScript POST 请求:包含数据和 Cookie 示例
您可以使用以下 JavaScript 代码来发送一个包含数据和 cookie 的 POST 请求:
var xhr = new XMLHttpRequest();
xhr.open('POST', '请求的URL', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Cookie', 'PHPSESSID=2vpr1m7b2cbo2g4mj353ge5kt7');
var data = JSON.stringify({
'web_domain': 'qq.com',
'WebIp': '103.45.140.15',
'serverType': 'server',
'serverGuid': '5c92VVFVUVVRVVFVUVdQVVBXU11T',
'api_type': 2,
'line_guid': '9a1dBlYGVgZWBlYGVgFXAVAEVAVSAVEFUgBSBVEH'
});
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
// 处理响应数据
}
};
xhr.send(data);
请将'请求的URL'替换为您要发送 POST 请求的目标 URL。
原文地址: https://www.cveoy.top/t/topic/jt8u 著作权归作者所有。请勿转载和采集!