problem in return value from server to client in ajax useing zend-framework

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/08 8:53 UTC
Read the original article Hit count: 288

Filed under:
|
|

hello i try to use ajax and zend 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?

$('#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() {

// action body

      $this->_helper->getHelper('viewRenderer')->setNoRender();
  // If you use layout, disable it
  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);

 }

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about jQuery