I'm wondering if there's an easy way to output an article as JsonP? I need to consume it in a sencha-touch application as a web s开发者_如何学Cervice
Callback({'response': [{'<div>some random html content</div>'}], 'success': true});
http://docs.joomla.org/Ajax_using_MooTools#Generating_JSON_output
<?php
// Set up the data to be sent in the response.
$data = array( 'some data' );
// Get the document object.
$document =& JFactory::getDocument();
// Set the MIME type for JSON output.
$document->setMimeEncoding( 'application/json' );
// Change the suggested filename.
JResponse::setHeader( 'Content-Disposition', 'attachment; filename="'.$view->getName().'.json"' );
// Output the JSON data.
echo json_encode( $data );
JSON Encode it with PHP.
http://php.net/manual/en/function.json-encode.php
精彩评论