AJAX URL routing to different controller

Hi Guys,

I’m trying to use AJAX to pull in the comments section on my site. Currently, the comments are handled by a module which are accessed like this:

@app/comments/com/comments?key=‘some key’

However, I’m using AJAX on a page with a completely different controller. What does my URL need to be to access the module action?

Mind you, the javascript is an external file, so I can’t “echo” the base url into the script.

Here’s my AJAX call.


function getComm() {

    $.ajax({

        url: 'comments?key=' + $('.title').data('key'),

        type: 'GET',

        dataType: 'HTML',

        success: function (result) {

            $('.comments').html(result);

        }

    });

}

That just routes to the current controller, which is not what I want. Aside from writing out the explicit url, what should the format be?

So this is embarrassing, as I have been stuck on this for several hours today and figured it out shortly after making this thread.

Anyway, I’ll at least post the solution in case others have the same problem.


function getComm() {

    $.ajax({

        url: '../comments/com/comments?key=' + $('.title').data('key'),

        type: 'GET',

        dataType: 'HTML',

        success: function (result) {

            $('.comments').html(result);

        }

    });

}

Two dots upfront did the trick.