I'm having promlem with sending post request in ajax request handler. In 
ajax request handler the body of response is always null, in the regular 
request handler it's not null. How to send http requests in ajax request 
handler?

class DataController extends AppController
{
    public function ajax_get_name()
    {
        $this->layout = 'ajax';
        $http = new HttpSocket();
        $res = $http->get('http://www.google.com/search', 'q=cakephp');
        if($res)
        {
            $data = json_decode($res->body);
            debug($data); // null
        }
    }

    publiс function index()
    {
                $http = new HttpSocket();
        $res = $http->get('http://www.google.com/search', 'q=cakephp');
        if($res)
        {
            $data = json_decode($res->body);
            debug($data); // *not *null
        }
    }
}

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to