我有一种形式,可以通过get方法向端点发出正确的请求。
var form = document.createElement('form');
with (form) {
setAttribute("name", "theForm"); // give form a name
setAttribute("action","PATHTO"); // give form an action
setAttribute("method", "get"); // give form a method
}
document.getElementsByTagName("body")[0].appendChild(form);
document.forms[0].submit();
但是,我需要在请求中设置一个具有键值对的标头,例如
ExtraInfo : 28473432894789238473293874329
我将如何使用javascript仅操作表格来进行操作。
您不能使用发送标头FORM
,而是可以使用XMLHttpRequest
以下方式实现标头:
var oReq = new XMLHttpRequest();
oReq.open("GET", "PATHTO");
oReq.setRequestHeader('ExtraInfo', 28473432894789238473293874329);
oReq.send();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句