We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to call a controller action using jquery ajax

Hi Guys Can I ask a question? How can I call a controller action when the page finishes loading?

here's the scenario after the page loads I'm going to call my mongocontroller and run indexaction here's my controller:

class MongoController extends ControllerBase
{
    public function indexAction()
    {   
        $count = new propertyCounts();
        $count->propertyID = &id;
        $count->views = 1;
    }
}

and also how can I increment it everytime a user view a property?

propertyCounts(); needs to be a model, if it is just add $count->save();, I'm unsure what you mean by "call a controller when the page finishes loading", if you're wanting to do an ajax request you need to use $.ajax https://api.jquery.com/jquery.ajax/