Hallo,
ich möchte gerne meine Sitebuilder-Erweiterung Grix fit für Contao 4.13 machen.
In dieser Version funktionieren nämlich die Ajax-Calls nicht mehr.
Sie liefern beim Aufruf hartnäckig ein 404 zurück.
Das ist meine 'routing.yml':
contao-grix-bundle/src/Resources/config/routing.yml
Code:
grix.contoller.grixsave:
path: /grixsave
defaults:
_controller: GeorgPreissl\ContaoGrixBundle\Controller\GrixController::save
_scope: frontend
_token_check: false
Das ist die Funktion im Controller dazu:
contao-grix-bundle/src/Controller/GrixController.php
Code:
<?php
namespace GeorgPreissl\ContaoGrixBundle\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Contao\ArticleModel;
use Contao\PageModel;
class GrixController extends Controller
{
public function save(Request $request)
{
$articleId = $request->request->get('articleId');
$grixJs = $request->request->get('grixjs');
$objResult = \Database::getInstance()->prepare("UPDATE tl_article SET grixJs=? WHERE id=?")->execute($grixJs, $articleId);
return new JsonResponse(array(
'data' => $objResult->affectedRows,
'status' => 'OK',
'message' => ['returntest', 'testarray']),
200);
}
}
Und so rufe dich die Route mit Javascript auf:
contao-grix-bundle/src/Resources/public/js/grix.js
Code:
$.ajax({
url: '/grixsave',
type: 'POST',
dataType: 'json',
data: {
articleId: obCfg.articleId,
grixjs: $('#ctrl_grixJson').val()
},
async: true,
success: function(data, status) {
window.location.href = '/contao?do=article&table=tl_content&act=create&mode=2&pid=' + obCfg.articleId + '&id=' + obCfg.articleId + '&grix=create&rt=' + obCfg.requTok + '&phid=' + stPhId + '&grixarticle=' + obCfg.articleId;
},
error: function(xhr, textStatus, errorThrown) {
console.log('hurrray it works!');
}
});
Leider bekomme ich bei dem Aufruf der Route stets die Fehlermeldung:
404-ajax.png
... in einer älteren Version von Contao hat das ganze noch geklappt.
Habt ihr vielleicht eine Ahnung woran das liegen könnte?
Vielen Dank für eure Hilfe!
Lesezeichen