[TYPO3-mvc] Extbase Backend Ajax Call

Andrea Schmuttermair abo at schmutt.de
Wed Jan 29 13:09:29 CET 2014


Hi,

still working on this issue, and the only solution I found is an  
old-fasioned Backend Extension, but no Extbase Solution?

Here is a nice Ajax Dispatcher:
http://daniel.lienert.cc/blog/blog-post/2011/04/23/typo3-extbase-und-ajax/
With some debugging and bugfixing I finally see my Extbase Action  
called in devlog.

Problem: I still have a full HTML page returned on response.

This is the important part of the Code:

public function dispatch() {
         (...)
         $request = $this->buildRequest();
//-> here the call of my Extbase Controller/Action is successful

         $response =  
$this->objectManager->create('Tx_Extbase_MVC_Web_Response');

         $dispatcher =  $this->objectManager->get('Tx_Extbase_MVC_Dispatcher');
         $dispatcher->dispatch($request, $response);
//-> response is a full HTML backend page. It contains the "return  
json_encode($test);" inside <body> tag.

         $response->sendHeaders();
         return $response->getContent();
     }

Currently I think about a starting and finishing string in my return  
value. Then i can get a substring from $response before sending it.  
But thats really ugly... any better ideas?

Best regards,
Andrea


Quoting Andrea Schmuttermair <abo at schmutt.de>:

> Hello,
>
> how can I create a ajax call in TYPO3 Backend using Extbase?
> In Frontend, I usually configure typeNum for Ajax rendering, but I  
> have no idea how to do that in a Backend Module.
> With this code, I get a successful Ajax return, but its content is a  
> complete HTML Page returned with <head> and everything.
> Important: needs to be running on TYPO3 Version 4.5
>
> Controller:
>
> class Tx_Test_Controller_TestController extends  
> Tx_Extbase_MVC_Controller_ActionController {
>
>     public function testAjaxAction() {
>          $test = array('test'=>1, 'test2'=>2);
>          return json_encode($test);
>     }
> }
>
> Fluid:
>
>
> <script type="text/javascript">
>   Ext.Ajax.request({
>     url: '<f:uri.action action="testAjax" />',
>     timeout: 60000,
>     method: 'GET',
>     scope: this,
>     params: '',
>     success: function(resp) {
>         console.log(resp);
>     },
>
> });
>
> Thanks for any advice!
> Andrea
>
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc





More information about the TYPO3-project-typo3v4mvc mailing list