Created
July 22, 2015 02:18
-
-
Save ericlbarnes/cec685ae9ea38afe57de to your computer and use it in GitHub Desktop.
Example delete request
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
$(document).ready(function() { | |
$("button.remove").on('click', function(e){ | |
e.preventDefault(); | |
if ( ! confirm('Are you sure?')) { | |
return false; | |
} | |
var action = $(this).data("action"); | |
var parent = $(this).parent(); | |
$.ajax({ | |
type: 'delete', | |
url: action, | |
data: '_token='+token, | |
beforeSend: function() { | |
parent.closest("tr").animate({'backgroundColor':'#fb6c6c'},300); | |
}, | |
error: function(msg) { | |
alert(msg.responseJSON[0]); | |
}, | |
success: function() { | |
parent.slideUp(300,function() { | |
parent.closest("tr").remove(); | |
}); | |
} | |
}); | |
}) | |
}); |
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
// Master layout: | |
<meta name="token" content="{{ csrf_token() }}"> | |
// Button: | |
<button class="btn btn-circle btn-danger remove" data-action="/users/delete/{{ $user->id }}"> | |
<i class="fa fa-trash-o"></i> | |
</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment