jQuery – AJAX Post method

Post method submits data to be processed to a specified resource. You have to remember setting Internet privilege for external scripts and data.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $.post("http://www.w3schools.com/jquery/demo_test_post.asp",
        {
          name: "Donald Duck",
          city: "Duckburg"
        },
        function(data,status){
var e1 = ('Data: ' + data + '<br> Status: ' + status);
document.getElementById("text").innerHTML = e1;
        });
    });
});
</script>
</head>
<body>

<button>Send an HTTP POST request to a page and get the result back</button>
<div id="text"></div>
</body>
</html>

Responses

0 Replies