Skip to content

Instantly share code, notes, and snippets.

@abbotto
Created April 13, 2015 16:47
Show Gist options
  • Select an option

  • Save abbotto/7169cc9e5180defe42f0 to your computer and use it in GitHub Desktop.

Select an option

Save abbotto/7169cc9e5180defe42f0 to your computer and use it in GitHub Desktop.
wBLZvX
<b>AJAX Calls</b><hr>
<div>
<button class='toggle-text'>This is XHR</button>
</div>
var div = $('<div>');
var $toggle = $('.toggle-text');
$toggle.add('next', div);
$toggle.on('click', function(){
$.relay('get', 'https://dl.dropboxusercontent.com/u/34263055/cdn/ajax-test-1.txt', function(data){
div.innerHTML = data;
});
});
$toggle.on('mouseover', function(){
$.relay('get', 'https://dl.dropboxusercontent.com/u/34263055/cdn/ajax-test-2.txt', function(data){
div.innerHTML = data;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment