【发布时间】:2015-04-21 20:27:25
【问题描述】:
我正在尝试使用前端插件的 Typo3 Extbase 控制器对 Datatable Serverside 进行 Ajax 调用,但无法获取表中的数据,而只能获取以下输出:
{"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):
<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):
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() {
}
}
使用的排版:
ajaxCall = PAGE
ajaxCall {
typeNum = 5000
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/json
xhtml_cleaning = 0
admPanel = 0
debug = 0
no_cache = 1
}
}
我错过了什么或做错了什么?
【问题讨论】:
-
您也可以使用eID call stackoverflow.com/questions/21139769/…
标签: ajax datatable typo3 extbase