Getting an Ajax response from Zend Framework Controller
- by JavaLava
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.