Skip to content

Instantly share code, notes, and snippets.

@ltackett
Created December 21, 2010 18:53
Show Gist options
  • Select an option

  • Save ltackett/750364 to your computer and use it in GitHub Desktop.

Select an option

Save ltackett/750364 to your computer and use it in GitHub Desktop.
// class and rel for grabbing a file and printing it inline via AJAX
var ajaxme = function(container, source){
$.ajax({
url: source,
success: function(data){
container.text(data);
},
error: function(){
container.html('File Not Found.')
}
})
}
$('.ajax-me').each(function(){
if ($(this).find('pre').hasClass('result') != true){
$(this).append('<pre class="result"></pre>')
var container = $(this).find('pre');
var source = $(this).attr('rel');
ajaxme(container, source);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment