I call the controller function:
$.get("http://localhost/universityapp/courses/listnames", function(data){ alert("Data Loaded: " + data); });
And in my controller:
public function listnames() { $data = Array( "name" => "Sergio", "age" => 23 ); $this->set('test', $data); $this->render('/Elements/ajaxreturn');
And in this view:
<?php echo json_encode($asdf); ?>
However, the action returns the entire page, including the contents of the layout (title, footer, navigation).
What am I missing here? How can I return only JSON data without layout content?
source share