发出POST请求的S3静态网站

问题描述 投票:0回答:1

是否可以从S3上托管的静态网站发出POSt请求?有任何解决方法吗?

javascript post amazon-s3 static
1个回答
0
投票

完全有可能,只需使用XMLHttpRequest或添加一些lib(jquery)即可帮助您:

<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>

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send

© www.soinside.com 2019 - 2024. All rights reserved.