Last active
March 24, 2017 16:40
-
-
Save larek/b5a859febccdf8d643429eeb24d8f20f to your computer and use it in GitHub Desktop.
Simple jquery post request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> | |
<script> | |
$(document).ready(function(){ | |
// Click on the button | |
$(".btn-send").click(function(){ | |
// Get values | |
var data1 = $(".data1").val(); | |
var data2 = $(".data2").val(); | |
// Send POST request | |
$.post('/server.php',{data1: data1, data2:data2 }).done(function(response){ | |
$(".result").html(response) | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<button class="btn-send">Кнопка</button> | |
<input type="text" class='data1'> | |
<input type="text" class='data2'> | |
<div class="result"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?= $_POST['data1'] + $_POST['data2'];?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment