Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>$.post()</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <button id="send">Create (POST)</button> <pre id="out"></pre> <script> $("#send").click(function(){ $.post("https://reqres.in/api/users", { name: "Sonu", job: "writer" }) .done(function(data){ $("#out").text(JSON.stringify(data, null, 2)); }) .fail(function(){ $("#out").text("POST failed (network/CORS)."); }); }); </script> </body> </html>
Output