質問編集履歴
2
postは、cakephpのコントローラの方のプログラムを改善したら、 データベースにデータがはいりましたが、 リロードしなければデータが反映されず困っています。
title
CHANGED
File without changes
|
body
CHANGED
@@ -111,4 +111,33 @@
|
|
111
111
|
//通信失敗時の処理
|
112
112
|
alert('通信失敗');
|
113
113
|
});}
|
114
|
+
```
|
115
|
+
|
116
|
+
```php
|
117
|
+
public function json_data(){
|
118
|
+
// $this->autoRender = FALSE;
|
119
|
+
$this->loadModel('Tweet');
|
120
|
+
$this->loadModel('Follow');
|
121
|
+
if($this->request->is('ajax')){
|
122
|
+
if(isset($this->data['tweet_id'])){
|
123
|
+
$this->Tweet->save($this->request->data);
|
124
|
+
//$this->redirect(array('action'=>'json_data'));
|
125
|
+
}
|
126
|
+
$id=$this->Auth->user('username');
|
127
|
+
$user_id=$this->Auth->user('id');
|
128
|
+
//フォロワーをfind指定
|
129
|
+
$all_follow=$this->Follow->list_all_follow($id);
|
130
|
+
$json_data=$this->Tweet->json_alluser_tweet_all($all_follow,$id);
|
131
|
+
//debug($json_data);
|
132
|
+
$this->viewClass = 'Json';
|
133
|
+
$this->set('my_id',$id);
|
134
|
+
$this->set('user_id',$user_id);
|
135
|
+
$this->set(compact('json_data'));
|
136
|
+
$this->set('_serialize',['user_id','my_id','json_data']);
|
137
|
+
}
|
138
|
+
/* }
|
139
|
+
else {
|
140
|
+
throw new BadRequestException();
|
141
|
+
}*/
|
142
|
+
}
|
114
143
|
```
|
1
配列変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -66,7 +66,7 @@
|
|
66
66
|
type:'post',
|
67
67
|
url: '/cakephp/users/json_data',
|
68
68
|
dataType: 'json',
|
69
|
-
data : {'tweet_id': user_id ,'username': my_id, 'tweet' : $('textarea').val()},
|
69
|
+
data : [{"Tweet":[{'tweet_id': user_id ,'username': my_id, 'tweet' : $('textarea').val()}]}],
|
70
70
|
timeout:10000,
|
71
71
|
success: function(data) {
|
72
72
|
console.log(user_id+' '+my_id+' '+$('textarea').val()+' '+time);
|