Skip to content

Instantly share code, notes, and snippets.

@Dexdot
Created August 28, 2017 15:41
Show Gist options
  • Select an option

  • Save Dexdot/3fd479156b432b32527b0637372ea393 to your computer and use it in GitHub Desktop.

Select an option

Save Dexdot/3fd479156b432b32527b0637372ea393 to your computer and use it in GitHub Desktop.
jquery ajax queries
$(function() {
var userName = $('form input').val();
$.ajax({
url: './send.php',
type: 'GET',
dataType: 'html',
data: {name: userName},
})
.done(function(data) {
console.log(data);
})
.fail(function() {
console.log("error");
});
});
// SEND.PHP:
$userName = $_GET['name']; // variable from ajax
echo 'Your name: '.$userName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment