TYPO3 extbase JSON输出 [英] Typo3 extbase json output

查看:171
本文介绍了TYPO3 extbase JSON输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建控制器来处理Ajax请求。

I try to create controller that handles ajax requests.

我发现,我已经把它添加到我的TS配置:

I found out, that I have to add this to my TS config:

ajaxCall = PAGE
ajaxCall {
    typeNum = 999
    config.disableAllHeaderCode = 1
    config.metaCharset = UTF-8
    xhtml_cleaning = 0
    admPanel = 0
    10 = COA
    10 < tt_content.list.20.registration_userregistration
}

和我的控制器是这样的:

And my controller looks like this:

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

    /**
     * @var string
     */
    protected $defaultViewObjectName = 'TYPO3\\CMS\\Extbase\\Mvc\\View\\JsonView';

    /**
     * action test
     *
     * @return string
     */
    public function testAction() {
        $this->view->assign('value', "001");
    }
}

这工作,我得到了一个空白页,上面有001。但是,如果我看源,有4个空行,而001是在5日线。

This works, I get a blank page with "001" on it. But if I look at the source, there are 4 empty lines, and "001" is in the 5th line.

-empty-
-empty-
-empty-
-empty-
"001"

我不知道为什么...

I have no idea why...

推荐答案

好了,我知道了......

Okay, I got it...

我附带一些功能命名为user.php的文件

I included a file with some functions named user.php

/**
 * User service
 *
 * @var \Whmcs\Registration\Service\User
 * @inject
 */
protected $user = NULL;

在这个文件中有对?>标签之后空行。这些空行都是问题。我删除了他们,现在一切工作正常。 :)

In this file there were empty lines after the ?> tag. These empty lines were the problem. I deleted them and now everything works fine. :)

这篇关于TYPO3 extbase JSON输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆