How to send POST request in JavaScript?

Posted on In QA

How to send POST request in JavaScript from the users’ browsers?

One easy method I find is to use the jQuery library’s post() method.

Here is one example that send POST request with data “file: filename” to the “/fileview” URL on the server and show the replied data:

$.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/

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *