for those of you that are using ZEND framework and want to know what i had to change in order to get this working ...
had to make changes on a couple of files:
1) added a new layout under VIEWS > LAYOUTS called json.phtml
<?php
header('Content-type: application/javascript');
echo $this->layout()->content;
?>
2) controller
added a new action called jsonAction
public function jsonAction()
{
$this->_helper->layout->setLayout('json');
$callback = $this->getRequest()->getParam('callback');
if ($callback != "")
{
// strip all non alphanumeric elements from callback
$callback = preg_replace('/[^a-zA-Z0-9_]/', '', $callback);
}
$this->view->callback = $callback;
// ...
}
3) added a new view under VIEWS > SCRIPTS > json.phtml
<?php
if ($this->callback != "")
{
echo $this->callback, '(', json_encode($response), ');';
}
else
{
echo json_encode($response);
}
?>
now i can make an ajax call via jquery like this:
$.ajax({
type: "GET",
url: 'http://<your_url>/<your_controller>/json',
data: {},
dataType: "jsonp",
success: function(json) {
console.log("success");
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("error("+jqXHR+", "+textStatus+", "+errorThrown+")");
}
});
maybe this helps someone ...