質問編集履歴
1
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
|
1
|
+
deleted!!!のアラートが出てしまい、errorにつながってしまいます。解決方法を教えていただければ嬉しいです。
|
2
2
|
|
3
3
|
```php(投稿の詳細のページのビューに設置している削除のボタン)
|
4
|
-
|
4
|
+
|
5
5
|
```
|
6
6
|
|
7
7
|
|
8
8
|
```php(コントローラー)投稿の削除メソッド
|
9
9
|
public function delete($id)
|
10
|
-
|
10
|
+
|
11
|
-
$articles = Article::findOrFail($id);
|
12
|
-
$articles->delete();
|
13
|
-
return redirect()->route('articles_index')->with('msg_success', 'deleted');
|
14
|
-
}
|
15
11
|
```
|
16
12
|
|
17
13
|
```javascript
|
@@ -19,27 +15,7 @@
|
|
19
15
|
e.preventDefault();
|
20
16
|
let deleteConfirm = confirm('are you sure?');
|
21
17
|
|
22
|
-
|
18
|
+
|
23
|
-
let clickEle = $(this)
|
24
|
-
let id = clickEle.attr('id');
|
25
|
-
|
26
|
-
$.ajax({
|
27
|
-
url: "{{URL::to('/articles')}}/" + id,
|
28
|
-
type: 'DELETE',
|
29
|
-
data: {
|
30
|
-
"_token": "{{ csrf_token() }}",
|
31
|
-
'id': id,
|
32
|
-
'_method': 'DELETE'
|
33
|
-
},
|
34
|
-
success: function () {
|
35
|
-
window.location.reload();
|
36
|
-
},
|
37
|
-
error: function (error) {
|
38
|
-
alert('deleted!!!');
|
39
|
-
console.log(error);
|
40
|
-
}
|
41
|
-
})
|
42
|
-
}
|
43
19
|
});
|
44
20
|
```
|
45
21
|
|