Javascript S3发出POST请求的静态网站
是否可以从S3上托管的静态网站发出POSt请求?有什么解决方法吗?完全可能,只需使用XMLHttpRequest或添加一些库(jquery)来帮助您:Javascript S3发出POST请求的静态网站,javascript,post,amazon-s3,static,Javascript,Post,Amazon S3,Static,是否可以从S3上托管的静态网站发出POSt请求?有什么解决方法吗?完全可能,只需使用XMLHttpRequest或添加一些库(jquery)来帮助您: <script> var xhr = new XMLHttpRequest(); xhr.open("POST", '/server', true); //Send the proper header information along with the request xhr.setRequestH
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", '/server', true);
//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() { // Call a function when the state changes.
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
// Request finished. Do processing here.
}
}
xhr.send("foo=bar&lorem=ipsum");
// xhr.send(new Int8Array());
// xhr.send(document);
</script>
var xhr=new XMLHttpRequest();
xhr.open(“POST”,“/server”,true);
//随请求一起发送正确的标头信息
setRequestHeader(“内容类型”,“应用程序/x-www-form-urlencoded”);
xhr.onreadystatechange=function(){//在状态更改时调用函数。
if(this.readyState==XMLHttpRequest.DONE&&this.status==200){
//请求已完成。请在此处进行处理。
}
}
发送(“foo=bar&lorem=ipsum”);
//send(新的Int8Array());
//发送(文件);