Created
January 21, 2013 17:13
-
-
Save WanaByte/4587541 to your computer and use it in GitHub Desktop.
Just a basic ajax example which works on JS bin.
This file contains hidden or 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
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.9.0.js"></script> | |
<script> | |
$(document).ready(function() { | |
$('a.ajax-trigger').on('click', function(event) { | |
event.preventDefault(); // Stop the click from going anywhere | |
$.ajax('/help', { | |
type: 'GET', | |
success: function (data, success, jqXHR) { | |
alert('worked'); | |
$('pre.ajax-data').html(data); | |
}, | |
failure: function (data, success, jqXHR) { | |
alert('failed'); | |
$('pre.ajax-data').html(data); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<a class="ajax-trigger" href="#">This will trigger an ajax request</a> | |
<div> | |
<pre class="ajax-data"><!-- This will get filled with the data from the request --> | |
This will be overwritten | |
</pre> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment