Skip to content

Instantly share code, notes, and snippets.

@corean
Created April 18, 2017 03:45
Show Gist options
  • Save corean/cee1e234ba6d56dd5953f27a062ea2d0 to your computer and use it in GitHub Desktop.
Save corean/cee1e234ba6d56dd5953f27a062ea2d0 to your computer and use it in GitHub Desktop.
CRUD중 Delete를 AJAX로 처리
<script>
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{csrf_token()}}'
}
});
$('.btn__delete').on('click', function (e) {
var boardID = '{{ $board->id }}';
var boardUri = '{{ $board->board_uri }}';
if (confirm('글을 삭제합니까?')) {
$.ajax({
type: 'DELETE',
url: '/admin/boards/' + boardUri + '/' + boardID
}).then(function () {
window.location.href = '/admin/boards/' + boardUri;
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment