Julian Schoemaker
Julian Schoemaker

Reputation: 103

Symfony server not getting POST parameters with AJAX

I'm having a very weird problem here. Everything was going well on my new website but now all my forms and CRUD functions on my admin panel are not working anymore. The problem is coming from the POST data that I send via Ajax, they do no arrive on my server, when i var_dump the $_POST variable, this one is empty. It is working fine with GET though... Here is an example of a typical Ajax call that i would use :

var envoi = {'search' : 'test'};
$.ajax({
    type: "POST",
    url: chemin,
    data: envoi,
    cache: false,
    success: function(data){
        ...
    }
});

Chrome console is showing that the form data is sent the right way... Now the most disturbing thing; i have no problem with the POST data on the other pages of my website, just on my admin panel, which are all the URLs matching /admin/* I used Symfony security for this :

firewalls:
    secured_area:
        pattern:   ^/
        anonymous: ~
        form_login:
            login_path:  /login
            check_path:  /login_check
            always_use_default_target_path: true
            default_target_path:            /admin
            use_referer:                    true
        logout:
            path:   /logout
            target: /login

access_control:
    - { path: ^/admin, roles: ROLE_ADMIN }

Off course, it all works perfectly on my local machine ... I've found many related subjects but the solutions didn't fix my problem. Thank you for helping me out.

EDIT The problem is not coming from Ajax, in fact all the POST data is not coming over...

Upvotes: 0

Views: 190

Answers (1)

Rejayi CS
Rejayi CS

Reputation: 1061

try with

var envoi = {search : 'test'};

Upvotes: 1

Related Questions