1
HTML:Sweetalertで確認ボタンを作成し、JavascriptとLaravel
<form id="myform" class="delete-photo col-md-12" method="POST" action="/admin/category/{{$catget->id}}">
<input type="hidden" name="_method" value="delete">
{{ csrf_field() }}
<div class="form-group">
<button type="submit" data-photo-id="{{$catget->id}}"
class="submitdel btn btn-danger"
>Delete Category</button>
</div>
</form>
のJs:
<script type="text/javascript">
$('.delete-photo').click(function(e) {
e.preventDefault(); // Prevent the href from redirecting directly
var linkURL = $(this).attr("action");
warnBeforeRedirect(linkURL);
});
function warnBeforeRedirect(linkURL) {
swal({
title: "Leave this site?",
text: "If you click 'OK', you will be redirected to " + linkURL,
type: "warning",
showCancelButton: true
}, function() {
// Redirect the user
window.location.href = linkURL;
});
}
</script>
私はsweetalertと確認ボタンを作成しようとしています。私は(http://localhost:8000/admin/category/13)であるルートを修正するためにリダイレクトするようにしようと試みたが、laravelは言う:RouteCollection.phpライン219で
MethodNotAllowedHttpException:....
私のルートは以下のとおりです。
Route::delete('/admin/category/{id}', '[email protected]');
何が間違っている可能性がありますか、その問題を修正しますか?
トークンCSRFを取っていなかったのjavascript previusはあなたがlaravel 5.1 –
を使用しているはい、私はルートが働いていると、ボタンがカテゴリを削除このjavasciptコードなしも追加する必要が laravel 5.1を使用しています。 –