TYPO3 后端:AJAX 和 jQuery(参数为空)
TYPO3 Backend: AJAX with jQuery (params empty)
根据后端 API:https://docs.typo3.org/typo3cms/CoreApiReference/JavaScript/Ajax/Backend/Index.html 我可以使用每个库在 TYPO3 后端进行 AJAX 调用。
我收到成功消息,但我的参数数组始终为空:
控制器
public function renderShowModal($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj = NULL){
var_dump($params);
}
jQuery
$.ajax({
type: 'POST',
url: TYPO3.settings.ajaxUrls['Controller::renderShowModal'],
data: {
"test": "bar"
},
success: function (result) {
console.log(result);
},
error: function (error) {
console.log(error);
}
});
我缺少什么或我必须如何发送我的数据?
它甚至不是这样工作的:
{"tx_ext_bm[test]": "bar"}
提前致谢
在我对此提出质疑的任何论坛中都没有答案,所以我最终使用 $_POST
.
以传统方式访问参数
根据后端 API:https://docs.typo3.org/typo3cms/CoreApiReference/JavaScript/Ajax/Backend/Index.html 我可以使用每个库在 TYPO3 后端进行 AJAX 调用。
我收到成功消息,但我的参数数组始终为空:
控制器
public function renderShowModal($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj = NULL){
var_dump($params);
}
jQuery
$.ajax({
type: 'POST',
url: TYPO3.settings.ajaxUrls['Controller::renderShowModal'],
data: {
"test": "bar"
},
success: function (result) {
console.log(result);
},
error: function (error) {
console.log(error);
}
});
我缺少什么或我必须如何发送我的数据?
它甚至不是这样工作的:
{"tx_ext_bm[test]": "bar"}
提前致谢
在我对此提出质疑的任何论坛中都没有答案,所以我最终使用 $_POST
.