Skip to content
Advertisement

AJAX values undefined with Symfony

I actually try to make an custom authentication using AJAX and Symfony but I have a problem that I can’t even identify. It seems that the AJAX part doesn’t find the route because my browser console can’t “recognize” my route script. I tried to identify AJAX data compared to input fields data and the problem is that AJAX returns undefined values. I’ll put the different parts of my code below :

Twig modal with AJAX script :

JavaScript

The PHP script :

JavaScript

Advertisement

Answer

As charlietfl said, you get different keys between your AJAX code and your PHP code. They should equal.

JavaScript

In your AJAX request, keys are pseudo and motdepasse. So, in your PHP code, you should use those keys like that:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement