質問編集履歴

2

postは、cakephpのコントローラの方のプログラムを改善したら、 データベースにデータがはいりましたが、 リロードしなければデータが反映されず困っています。

2016/10/25 06:14

投稿

usuallyi
usuallyi

スコア41

test CHANGED
File without changes
test CHANGED
@@ -225,3 +225,61 @@
225
225
  });}
226
226
 
227
227
  ```
228
+
229
+
230
+
231
+ ```php
232
+
233
+ public function json_data(){
234
+
235
+ // $this->autoRender = FALSE;
236
+
237
+ $this->loadModel('Tweet');
238
+
239
+ $this->loadModel('Follow');
240
+
241
+ if($this->request->is('ajax')){
242
+
243
+ if(isset($this->data['tweet_id'])){
244
+
245
+ $this->Tweet->save($this->request->data);
246
+
247
+ //$this->redirect(array('action'=>'json_data'));
248
+
249
+ }
250
+
251
+ $id=$this->Auth->user('username');
252
+
253
+ $user_id=$this->Auth->user('id');
254
+
255
+ //フォロワーをfind指定
256
+
257
+ $all_follow=$this->Follow->list_all_follow($id);
258
+
259
+ $json_data=$this->Tweet->json_alluser_tweet_all($all_follow,$id);
260
+
261
+ //debug($json_data);
262
+
263
+ $this->viewClass = 'Json';
264
+
265
+ $this->set('my_id',$id);
266
+
267
+ $this->set('user_id',$user_id);
268
+
269
+ $this->set(compact('json_data'));
270
+
271
+ $this->set('_serialize',['user_id','my_id','json_data']);
272
+
273
+ }
274
+
275
+ /* }
276
+
277
+ else {
278
+
279
+ throw new BadRequestException();
280
+
281
+ }*/
282
+
283
+ }
284
+
285
+ ```

1

配列変更

2016/10/25 06:14

投稿

usuallyi
usuallyi

スコア41

test CHANGED
File without changes
test CHANGED
@@ -134,7 +134,7 @@
134
134
 
135
135
  dataType: 'json',
136
136
 
137
- data : {'tweet_id': user_id ,'username': my_id, 'tweet' : $('textarea').val()},
137
+ data : [{"Tweet":[{'tweet_id': user_id ,'username': my_id, 'tweet' : $('textarea').val()}]}],
138
138
 
139
139
  timeout:10000,
140
140