jQuery ajax get() pass parameter to php and get result from php

Description

jQuery ajax get() pass parameter to php and get result from php

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of Sending Data with Ajax GET Request in jQuery</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        // Get value from input element on the page
        var numValue = $("#num").val();

        // Send the input data to the server using get
        $.get("your script.php", {number: numValue} , function(data){
            // Display the returned data in browser
            $("#result").html(data);
        });//  ww  w.  j  a va  2 s.  co  m
    });
});
</script>
</head>
<body>
    <label>Enter a Number: <input type="text" id="num"></label>
    <button type="button">Show Multiplication Table</button>
    <div id="result"></div>
</body>
</html>



PreviousNext

Related