Home>

I passed the ajax written by jquery to the cakephp controller, but it became null and I could not pass the value well.

Corresponding source code
$(.class) .on ('change', function () {
        let abc = "3"
        $.ajax ({{
            dataType: "json",
            type: "POST",
            url: baseUrl + languages ​​+ "/ controller name/action name",
            data: abc,
            success: function (data) {
                console.log (abc);
            },
            error: function () {
                console.log ("failed");
            },
        });
public function action name () {
        $ajaxData = $_POST ['abc'];
}
What I tried

In jQuery console.log, the value with 3 in abc comes out properly, so I think that the javascript file is correct, but if it is a php file, it will be null.

What's wrong with the above code?
I would appreciate it if you could teach me.

Related questions