一、GET请求
#FBrowser浏览器测试 可用 function TestA(url){ var req = new XMLHttpRequest(); req.open('GET', url, false); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //设置协议头 req.send(); return req.responseText } TestA('https://lumtest.com/myip.json');
二、POST请求
#FBrowser浏览器测试 可用 function URL_POST(url){ var req = new XMLHttpRequest(); req.open('POST', url, false); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //设置协议头 req.send("locationType=LOCATION_INPUT&zipCode=10021&storeContext=generic&deviceType=web&pageType=Gateway&actionSource=glow"); return req.responseText } URL_POST('http://lumtest.com/myip.json');
三、通过JS脚本 上传文件格式 FormData()
// 定义请求参数
const url = 'https://api.baidu.com/secure/api/order/#订单号长#/items/action';
const headers = {
'authority': 'api.baidu.com',
'user-agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',
'accept': '*/*',
'referer': 'https://api.baidu.com/secure/order/#订单号短#',
'accept-language': 'zh-CN,zh;q=0.9',
};
// 创建 FormData 对象
const formData = new FormData();
formData.append('action', 'confirm');
formData.append('orderNumber', '#订单号短#');
formData.append('estDeliveryDate', '#pdate#T15:03:30+08:00');
formData.append('msgToCustomer', '');
formData.append('selectedItems', '#item_strs#');
formData.append('itemStrs', '#item_strs#');
formData.append('quantities', '#qty#');
// 发送请求
fetch(url, {
method: 'POST',
headers: headers,
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text();
})
.then(data => {
console.log('Success:', data);
})
.catch(error => {
console.error('Error:', error);
});


赞
打赏
生成海报

发表回复
评论列表(10条)
功能强大,GET和POST请求测试方便快捷!
功能强大,GET和POST请求都测试成功!简单易用。
功能强大,GET/POST请求测试方便快捷!
功能强大,GET和POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET和POST请求测试顺利完成!数据返回迅速准确。
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!
功能强大,GET/POST请求测试方便快捷!