How to send POST request in JavaScript?

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

related to an answer for: How to parse POST data in node.js?
asked Oct 15, 2015 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

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/

answered Oct 15, 2015 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...