Skip to content

Instantly share code, notes, and snippets.

@codersatx
Created May 20, 2011 02:30
Show Gist options
  • Save codersatx/982240 to your computer and use it in GitHub Desktop.
Save codersatx/982240 to your computer and use it in GitHub Desktop.
Some arbritrary jquery.
$(document).ready(function(){
$('.btn-delete-workflow-comment').click(function(e){
e.preventDefault();
var url = $(this).parent().attr('href') + '/do';
$(this).parent().parent().parent().fadeOut('slow');
ajax_request(url);
});
$('.btn-delete-image').click(function(e){
e.preventDefault();
var url = $(this).parent().attr('href') + '/do';
$(this).parent().parent().parent().fadeOut('slow');
ajax_request(url);
});
function ajax_request(url)
{
var str = 'data';
$.ajax({
type: "POST",
url: url,
data: str,
success: function(msg){
if(msg == 'OK')
{
$('#ajax-message').text('Your action was successful.');
$('#ajax-message').attr('class','success message');
$('#ajax-message').fadeIn('slow');
setTimeout(function(){ $('#ajax-message').fadeOut('slow') }, 3000);
}
else
{
$('#ajax-message').text('There was an error.');
$('#ajax-message').attr('class','error message');
$('#ajax-message').fadeIn('slow');
setTimeout(function(){ $('#ajax-message').fadeOut('slow') }, 3000);
}
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment