2015-04-21 31 views
0

我试图与一个TYPO3的Extbase控制器Ajax调用的数据表Serverside集团的前端插件,但在表中不能得到的数据,而不是只有下面的输出:使用Ajax调用的数据表Serverside集团与TYPO3的Extbase控制器功能

<f:layout name="Default" /> 
<f:section name="main"> 

<table id="example" class="display" cellspacing="0" width="100%"> 
    <thead> 
     <tr> 
      <th>Field 1</th> 
      <th>Field 2</th> 
      <th>Field 3</th> 
      <th>Field 4</th> 
      <th>Field 5</th> 
      <th>Field 6</th> 
     </tr> 
    </thead> 

    <tfoot> 
     <tr> 
      <th>Field 1</th> 
      <th>Field 2</th> 
      <th>Field 3</th> 
      <th>Field 4</th> 
      <th>Field 5</th> 
      <th>Field 6</th> 
     </tr> 
    </tfoot> 
</table> 

<script type="text/javascript" src="typo3conf/ext/ffs_datatables/Resources/Public/ajaxFunctions.js"></script> 

</f:section> 

我的js函数(ajaxFunctions.js):

{"sEcho":0,"iTotalRecords":"6","iTotalDisplayRecords":"6","aaData":[["1","Hans","Meier","51","2011-04-13","EUR200"],["2","Frank","Heinz","45","2004-02-17","EUR60"],["3","Katrin","Kohl","35","2011-08-17","EUR1000"],["4","Werner","Pertl","39","2013-11-19","USD499"],["5","Christina","Sinn","22","2015-03-09","GBP99"],["6","Klaus","Vienna","67","1991-01-15","EUR5000"]]} 

我用下面的视图(list.html)

var MY_AJAX_ACTION_URL = '<f:uri.action action="list" controller="DatatableController" pageType="5000" />'; 

$(document).ready(function() { 
    $('#example').dataTable({ 
    "bProcessing": true, 
    "bServerSide": true, 
    "sAjaxSource": { 
     type: 'POST', 
     url: MY_AJAX_ACTION_URL   
    } 
    }); 
}); 

..和我的控制器:

namespace myVendor\FfsDatatables\Controller; 

/** 
* DatatableController 
*/ 
class DatatableController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController { 

/** 
* action list 
* 
* @return void 
*/ 
public function listAction() { 

...,我从包括以下语句:https://datatables.net/development/server-side/php_mysql这里和回报交换回声......

return json_encode($output); 
} 
/** 
* action 
* 
* @return void 
*/ 
public function Action() { 
} 
} 

Typo脚本中使用:

ajaxCall = PAGE 
ajaxCall { 
    typeNum = 5000 
    config { 
    disableAllHeaderCode = 1 
    additionalHeaders = Content-type:application/json 
    xhtml_cleaning = 0 
    admPanel = 0 
    debug = 0 
    no_cache = 1 
    } 
} 

我在想什么或做错了什么?

+0

你也可以使用eID调用http://stackoverflow.com/questions/21139769/typo3-extbase-ajax-without-page-typenum#32225730 –

回答

1

我想你一定在你的Typo脚本中添加一行从哪里得到您的页输出:

ajaxCall = PAGE 
ajaxCall { 
    typeNum = 5000 
    config { 
    disableAllHeaderCode = 1 
    additionalHeaders = Content-type:application/json 
    xhtml_cleaning = 0 
    admPanel = 0 
    debug = 0 
    no_cache = 1 
    } 
    10 < tt_content.list.20.yourextensionname_yourpluginname 
} 

如果没有帮助,你应该考虑不只是在你的行动回报您的数据,但使用Extbase 6.2以来的JsonView。也许这可以给你更多的帮助: Typo3 extbase json output

相关问题