简体   繁体   English

带有原始HTTP请求的AJAX发布请求-Javascript

[英]AJAX Post Request with Raw HTTP Request - Javascript

I am looking for a way to send the following POST request using only plain Javascript: 我正在寻找一种仅使用纯Javascript发送以下POST请求的方法:

Let's say the above HTTP request was a variable, would it maybe be possible to send that as a request and gather the result? 假设上述HTTP请求是一个变量,是否有可能将其作为请求发送并收集结果? Or is it a better way to send this POST request using Javascript? 还是使用JavaScript发送此POST请求的更好方法?

Thanks in advance for all answers. 在此先感谢您提供所有答案。

Something like this should work as long as it is your own api that you are calling to? 只要您要调用的是您自己的api,类似的东西就应该起作用?

var post = function() {
  var url = "http://www.example.com";
  var request = new XMLHttpRequest();
      request.open( "POST", url, true);
      request.send(null);   
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM