Joomla: Как я могу вывести статью как JsonP? - PullRequest
1 голос
/ 28 июня 2011

Мне интересно, есть ли простой способ вывести статью в виде JsonP?Мне нужно использовать его в приложении в качестве веб-службы

Callback({'response': [{'<div>some random html content</div>'}], 'success': true});

Ответы [ 2 ]

3 голосов
/ 28 июня 2011

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 );
0 голосов
/ 28 июня 2011

JSON Закодируйте его с помощью PHP.

http://php.net/manual/en/function.json-encode.php

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...