Created
December 18, 2015 10:17
-
-
Save mikedhart/9c9ffbeb491b44fb768b to your computer and use it in GitHub Desktop.
Event listener/AJAX example
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> | |
</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