开发者

Joomla: How can I output an article as JsonP?

开发者 https://www.devze.com 2023-03-15 15:27 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消