sending ajax request to a module service without no ajaxController

28 views Asked by At

I want to count how many times my menu items are clicked. for this task, I have a visited cell in my menu table that is retrieved by some models. the menu items are shown on my layout.phtml each specified by their id and I am trying to use ajax for this matter as below:

### menu items in layout.phtml

<li><a href="#" id="menuItems" data_id="mydata511">about</a></li>

### ajax code
    $(document).ready(function(){
        $('a#menuItems').click(function () {
            var data={};
            data.id =$(this).attr("data_id");
            $.ajax({
                type : 'POST',
                url  :'../../../module/Application/src/Model/visitCounter.php',
                data :data,
                success: function(data){
                },
                error:function(){
                }
            });
        });
    });

the visitCounter.php is a service model that gets the variables via POST method do the rest of the work but the problem is how to send this ajax request to the service model page. I wonder if there is a way to achieve that without any controller. I really appreciate if anyone could help me with this.

0

There are 0 answers