problem in json response from server to client using jquery

Posted by user1400 on Stack Overflow See other posts from Stack Overflow or by user1400
Published on 2010-04-08T08:47:10Z Indexed on 2010/04/09 6:13 UTC
Read the original article Hit count: 385

Filed under:
|
|
|
|

hello i try to use ajax and zend framework in my application , i could pass variable to server

but i can not get data from server , it does not return values,

it return all html code page,

where is my mistake? or should i config other thing?

$('#myForm').submit(function($e){

 $e.preventDefault();
   var $paramToServer=$("#myForm").serialize();

    $.ajax({
        type:'POST',
        url:'test',
        data:$paramToServer ,
        success:function(re){
            var res = $.evalJSON(re);
             console.log(res.id); // to see in firebog

        },
        dataType:'json'
    });

});

public function testAction() {

          $this->_helper->getHelper('viewRenderer')->setNoRender();
     //disable layout 
         Zend_Layout::getMvcInstance()->disableLayout();

         $name=$this->getRequest()->getParam ( 'name' ); //pass $name to server

           $return = array(
         'id' => '5',
         'family' => 'hello ',

      );
          $return = Zend_Json::encode( $return);

      // Response
             $this->getResponse()->setBody($return);

     }

thanks

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about jQuery