by
19
6
2,948
1
Top 1% !
Popular
Famous
Nice
Specified
Pattern
Popularity: 4832nd place
No tags for this snippet yet.
LanguagePHP
LicenseMIT_X11
SourceGitHub
TechnologyAJAX

Ajax Request

Ajax Request: 
laravel-ajax.php
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/197663/Ajax-Request?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
{{ link_to_action('PostsController@edit', 'Edit', $post->id, array('class' => 'btn btn-default')) }} <button type="button" class="btn btn-danger delete-btn" data-post-id="{{{ $post->id }}}">Delete</button> <script> var csrfToken = "{{{ Session::get('_token') }}}"; $(".delete-btn").click(function() { var postId = $(this).data('post-id'); if (confirm('Are you sure you want to delete this post?')) { $.ajax({ url: '/posts/' + postId, type: 'post', data: { _token: csrfToken, _method: 'delete' }, success: function(data) { // Alert success } }); } }); </script>
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus