Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Event listener/AJAX example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a href="#" id="click_me">Click me</a>
<div id="response_holder">Nothing here!</div>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).on('ready', function (e) {
$('#click_me').on('click', function (e) {
url = "/";
$.ajax({
method: 'get',
url: url,
data: {
aidan: 'cool',
mike: 'un-cool'
},
success: function (resp) {
alert('Yay');
//$('#response_holder').html(resp);
},
error: function (xhr) {
alert('Nay!');
}
});
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.