[TYPO3-german] AJAX im Plugin mit eID - Zugriff auf Session

Dr. Dieter Porth web37p2 at web59550.greatnet-hosting.de
Sat Jun 17 15:51:31 CEST 2017


Es gilt immer noch im TypoScript?

=======================================

ajax = PAGE
ajax {
typeNum = 99
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/json
admPanel = 0
debug = 0
}
10 < tt_content.list.20.kksession2_kksession2

==================================
Wie sieht denn deine Plugin-Definition aus? Nicht, dass das 
kksession2_kksession2 gar nicht mehr definiert ist.
Probiere aus, ob überhaupt dein Page-Type gezogen wird. Da du die 
aktuelle Seite angezeigt bekommst, scheint dein TypeNum nicht zu greifen.

=======================================

ajax = PAGE
ajax {
typeNum = 99
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/json
admPanel = 0
debug = 0
}
10 = TEXT

10.value = Ich funktioniere wirklich

10.wrap = <h1>|</h1>

==================================

Gib mal zusätzlich beim <f:uri> den Namen des Plugin an, zu welchem die 
Action und der Controller gehören.  (Attribute pluginName) Wenn ich mich 
richtig erinnere, sollte es dann auch ohne Pagetype funktionieren.

 >    public function sessionAction() {
 >       return $this->view->assign('wert', 'test');
 >   }
Ist Unsinn, weil
a) das 'return' in einer Action verhindert, dass der View ausgeführt 
wird (laut Anmerkung zur Frage 3.3 in "TYPO3 CMS Certified Develeoper)
b) $this->view->assign('wert', 'test');   nur $this zurückgibt.

Dieter

Am 17.06.2017 um 14:09 schrieb David Brünner:
>> Dann solltest du 
> sie auch als sessionAction bezeichnen
>
> Das hatte ich schon Probiert.
> Habe aber jetzt mal zwei Varianten -  zwei versch. Controller - getestet:
>
> IndexController:
> <?php
> namespace KKSoftware\Kksession\Controller;
>
> use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
>
> class IndexController extends ActionController {
>
>     public function indexAction() {
>     }
>
>     public function sessionAction() {
>         $this->view->assign('test', 'wert');
>     }
>
> }
>
> SessionController:
> <?php
> namespace KKSoftware\Kksession\Controller;
>
>
> use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
>
> class SessionController extends ActionController {
>
>     /**
>      * @var \TYPO3\CMS\Extbase\Mvc\View\JsonView
>      */
>     protected $view;
>
>     /**
>      * @var string
>      */
>     protected $defaultViewObjectName = 
> \TYPO3\CMS\Extbase\Mvc\View\JsonView::class;
>
>     public function sessionAction() {
>         return $this->view->assign('wert', 'test');
>     }
> }
>
> Und in meinem View dann:
> <script>
>     var ajaxUrl = '<f:uri.action action="session" controller="Index" 
> pageType="99"/>';  <!-- Controller: Index -->
> </script>
> oder
> <script>
>     var ajaxUrl = '<f:uri.action action="session" controller="Session" 
> pageType="99"/>';  <!-- Controller: Session -->
> </script>
>
> Im Templates/Session/Session.html bzw. Templates/Index/Session.html 
> steht immer nur: {wert}
>
> Beide Fälle liefern das gleiche Ergebnis. Ich bekomme immer das zurück 
> geliefert - den Inhalt der aktuellen Seite.
> Also ich meine die Entwicklerkonsole zeigt im Response-Tab die 
> aktuelle Seite an.
>
>
> Das sagt die Entwicklerkonsole:
> Request 
> URL:http://localhost/typo8/index.php?id=1&type=99&tx_kksession_kksession%5Baction%5D=session&tx_kksession_kksession%5Bcontroller%5D=Session&cHash=79997d7538aed3f47cc54a1884861aae
> Request Method:POST
> Status Code:200 OK
>
> bzw.
> Request 
> URL:http://localhost/typo8/index.php?id=1&type=99&tx_kksession_kksession%5Baction%5D=session&tx_kksession_kksession%5Bcontroller%5D=Index&cHash=110588b4f0d2913288e34c9d28da1e0b
> Request Method:POST
> Status Code:200 OK
>
> Obwohl mein JS $().ready(function () {
>     $.ajax({
>         url: ajaxUrl,
>         type: 'post',
>         dataType: 'json',
>         success: function(result) {
>             alert(result);
>         },
>         error: function(result) {
>             console.log('ERROR');
>             console.log(result);
>         }
>     });
> });
>
> mir nicht den erwarten alert() ausgibt sondern den Error-Teil.
>
> _______________________________________________
> TYPO3-german mailing list
> TYPO3-german at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german

-- 
----
Dr. Dieter Porth - Web-Entwickler



More information about the TYPO3-german mailing list