Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Created January 3, 2019 20:23
Show Gist options
  • Save tieutantan/187364b1aba5dfac8e2d5d634828b3ea to your computer and use it in GitHub Desktop.
Save tieutantan/187364b1aba5dfac8e2d5d634828b3ea to your computer and use it in GitHub Desktop.
Use jQuery Ajax with PHP
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$.ajax({
url:"info.php",
type:'POST',
data:{name:your_name,age:your_age},
dataType:"html",
success:function(res) {
console.log(res);
}
error:function(error) {
console.log(error);
}
})
</script>
<?php
$name = $_POST['name'];
$age = $_POST['age'];
echo "Success";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment