How to send POST request in JavaScript from the users’ browsers?
如何通过JavaScript从用户浏览器发送POST请求?
One easy method I find is to use the jQuery library’s post()
method.
我发现一种简单的方法是使用jQuery 库的post()
方法。
Here is one example that send POST request with data “file: filename” to the “/fileview” URL on the server and show the replied data:
这是一个示例,该示例将带有数据“ file:filename”的POST请求发送到服务器上的“ / fileview” URL,并显示已回复的数据:
$.post("/fileview", {file: filename}, function (data) {
// actions upon receiving the reply
alert("Data received: " + data);
});
More details, please check manual of jQuery.post() manual: http://api.jquery.com/jquery.post/
更多详细信息,请查看jQuery.post()手册: http : //api.jquery.com/jquery.post/
翻译自: https://www.systutorials.com/how-to-send-post-request-in-javascript/