Skip to content
Advertisement

How to pass a AJAX call on OctoberCMS

Im using OctoberCMS, the user plugin and I want to send data via AJAX to a controller and save the data in the database (in the column of the logged in user).

So I created a new Route in my routes.php

JavaScript

And a controller

JavaScript

And my jQuery calls

JavaScript

But nothing works. If I call /saveHighscore in my browser with dummy data in the controller, it works fine

Advertisement

Answer

It should work without any issue.

But I think you are making 2 different requests

In ajax config you specified -> type: "POST" and you are listening for get request

May be you just need to change Route::get -> Route::post

Now it should work expected.

If any doubts please comment.

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