jQueryAjax-如何仅在joomla组件返回时获取文本?
使用jQueryAjax时,如何获取joomla2.5组件仅返回文本? 因为现在我得到了完整的html。我尝试添加“&format=raw”,但没有效果! 如何修复它 jQueryjQueryAjax-如何仅在joomla组件返回时获取文本?,jquery,joomla,Jquery,Joomla,使用jQueryAjax时,如何获取joomla2.5组件仅返回文本? 因为现在我得到了完整的html。我尝试添加“&format=raw”,但没有效果! 如何修复它 jQuery $.ajax({ type: "POST", url: "index.php?option=com_test&task=edit", ...................... 当我需要输出一些JSON时,我通常不让控制器进入视图。我将所需的数据放入对象并将其传递给此函数: function
$.ajax({
type: "POST",
url: "index.php?option=com_test&task=edit",
......................
当我需要输出一些JSON时,我通常不让控制器进入视图。我将所需的数据放入对象并将其传递给此函数:
function jsonOut($obj) {
$app = JFactory::getApplication();
JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true ); // Expires in the past
JResponse::setHeader( 'Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true ); // Always modified
JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false );
echo json_encode($obj);
$app->close();
}
不需要查看。它只是抛出了JSON。您只需在任务结束时添加Jexit()&您将摆脱完整的html。您也可以使用die(),但如果有Jexit(),为什么呢。干杯
如果您不想在ajax响应中添加额外的html,只需输出所有文本并放入die();最后。此链接可能会为您提供更多详细信息
function edit()
{
// Your code
Jexit();
}