Skip to content

Instantly share code, notes, and snippets.

@NightOwlPrgmr
Last active July 9, 2016 16:11
Show Gist options
  • Save NightOwlPrgmr/b50a2a37e4c41f2593bb to your computer and use it in GitHub Desktop.
Save NightOwlPrgmr/b50a2a37e4c41f2593bb to your computer and use it in GitHub Desktop.
Basic AJAX Example
var request = {};
request['action'] = 'submit';
request['data'] = $(this).val() || $(this).closest('form').serialize();
$.ajax({
url: "<?= $URL; ?>", || url: 'someFile.php',
data: request, || JSON.stringify(request), ||
type: 'POST',
cache: false,
dataType: 'json'
}).done(function(response) {
// done function
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment