質問編集履歴
2
開演
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
また、function(res)の意味がりかいできないのですが、こちらはどういったいみなのでしょうか?
|
8
8
|
引数なのでしょうか?
|
9
9
|
|
10
|
-
```php(jsを埋め込んでます。)
|
10
|
+
```edit.ctp{php(jsを埋め込んでます。)}
|
11
11
|
<script>
|
12
12
|
|
13
13
|
$(function() {
|
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,3 +26,24 @@
|
|
26
26
|
```
|
27
27
|
|
28
28
|
|
29
|
+
```cakephpのPostscontroller.php
|
30
|
+
public function delete($id) {
|
31
|
+
if ($this->request->is('get')) {
|
32
|
+
throw new MethodNotAllowedException();
|
33
|
+
}
|
34
|
+
|
35
|
+
if ($this->request->is('ajax')) {
|
36
|
+
if ($this->Post->delete($id)) {
|
37
|
+
$this->autoRender = false;
|
38
|
+
$this->autoLayout = false; // この2つはajax処理をするときの決り文句
|
39
|
+
$response = array('id' => $id); // idをjson形式で返す
|
40
|
+
$this->header('Content-Type: application/json');
|
41
|
+
echo json_encode($response);
|
42
|
+
exit();
|
43
|
+
}
|
44
|
+
}
|
45
|
+
$this->redirect(array('action' => 'index'));
|
46
|
+
}
|
47
|
+
```
|
48
|
+
|
49
|
+
|