Ajax Post Request Returns DispatchException

Hello! I'm trying to post a value of a range input to my controller. When I try to do this it throws a DispatchException with the following message: 'ControllersController handler class cannot be loaded'.

Here is my Javascript/JQuery code:

$(document).ready(function(){
    $('#number_of_rooms').on("change mousemove", function() {
        $.ajax({
            method: "POST",
            url: "controllers/LocationController",
            data: {'value':this.value}
        })
    });
});

And here is the full error message I get as the POST response:

ControllersController handler class cannot be loaded

#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('ControllersCont...', 2)
#1 [internal function]: Phalcon\Dispatcher->_dispatch()
#2 [internal function]: Phalcon\Dispatcher->dispatch()
#3 D:\wamp64\www\feestlocatie\public\index.php(39): Phalcon\Mvc\Application->handle()
#4 {main}

I'm currently creating this application on my localhost using a wamp server, maybe that is the issue?

What I eventually want to achieve is to update information I pull out of my model dynamically when you change the value of the sliders. For example, my data contains information about a location. And I would only wnat to show any location with the "numberofrooms" below the value of my slider.

Keep in mind that I'm very new to phalcon, but do have some experience in regular web development.

Could anybody help me with this please?



341

Can you please share the source of the said controller. Anyway, what is "url: "controllers/LocationController",???? Are you reffering to Location Controller to pull the data?

Can you try such $.post("{{ url('location/available') }}"

Where location is the controllerName and available as the action method.

Likewise on available method you should check if the request is via Ajax like if ($this->request->isAjax()) { //return false; to disable view }



29.9k

Hi,

there's something wrong in:

url: "controllers/LocationController",

should be "controllerName/actionName", like "user/register" for UserController and registerAction()

why are you posting to the controllers folder ? create a route and send the post request