Change the text of a <div> element using an AJAX POST request - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:post

Description

Change the text of a <div> element using an AJAX POST request

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input").keyup(function(){
        var txt = $("input").val();
        $.post("demo.asp", {suggest: txt}, function(result){
            $("span").html(result);
        });/*ww  w  .ja  v  a  2  s  . com*/
    });
});
</script>
</head>
<body>

First name:<input type="text">

<p>Suggestions: <span></span></p>
</body>
</html>

Related Tutorials