Friday, May 22, 2015

CakePHP 3 Ajax Call Performance issue

we have done the below code element ( text posting by ajax ) in cakephp 2.5 later we changed to cakephp 3 , it seems like the performance of the function is diminished to a very noticeable extend in cakephp 3 (mainly speed is decreased 250 ms to 1.4s) thanks in advance:)

// ajax call to save post                      $.ajax({                                  type: "POST",                                  url: baseUrl + 'posts/add',                                  data: data,                                  dataType: "json",                                  success: function(response, status) {                                            if(!response.success) {                                                  alert('An unexpected error has occurred!');                                          }else{                                            append_post(response.post_id);                                          }                                    },                                  error: function(response, status) {                                      console.log(response);                                          alert('An unexpected error has occurred!!');                                  }                      });        //posts/add  function        public function add()      {   $this->layout ='ajax';          $this->autoRender = FALSE;            $post = $this->Posts->newEntity();            if ($this->request->is('post')) {                $status['success'] = FALSE;                $post = $this->Posts->patchEntity($post, $this->request->data);                  if ($this->Posts->save($post)) {                 $status['success'] = True;                  $status['post_id'] = $post->id;                 }              $this->response->body(json_encode($status));              return $this->response;          }          }   

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: