Getting an Ajax response from Zend Framework Controller

Posted by JavaLava on Stack Overflow See other posts from Stack Overflow or by JavaLava
Published on 2012-06-07T04:35:13Z Indexed on 2012/06/07 4:40 UTC
Read the original article Hit count: 121

Filed under:
|
|

I'm doing an Ajax request on one of my views to a Controller but I am unable to send back a response to the Ajax method. In the snippet below, I am trying to send the word 'hellopanda' back but in the alert message, I'll get data as an object.

View :

$.ajax({

  type: "POST",  
  url: "localhost/some-activity",
  data: dataString, 
  success: function(data) { 
          alert( "Data is: " + data);
      //do something with data
  },
  error: function(data){
           alert( "Data is: " + data);
    //do something with data 
      },
  onComplete: function(){

      }
});

Controller:

public function someActivityAction(){

//do stuff echo "hellopanda";

}

I'm pretty sure the echo is the problem. Any insights on to how to do a proper response to the view would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about zend-framework