2

I'm creating a web app without any framework and I need a route. So i found AltoRoute as interesting solution. But I really don't understand how this working, I have read the documentation page but I have some question to ask. Hope that some one could help. I'll organize the question in step for more precision:

  1. How can I import the controllers?

my app structure look like this:

PUBLIC HTML
     App_name
         APPLICATION
             CONTROLLERS
             LIBRARIES
             MODELS
             VIEW
         SYSTEM 'in this folder I have inserted altoroute

I have all the controllers and the php backend inside the application folder. I want import all controllers available in controllers folder in AltoRouter. I tried with this:

require "AltoRouter.php";
$router = new AltoRouter();

$router->setBasePath("/App_name/system");

$router->map("GET|POST", "../application/controllers/backend.php");

is this good for import the controller?

  1. How I can call specific function of the controller loaded?

In the past when I use CodeIgniter I perform this operation for load a function inside the controller:

$this->load->model('backend');
$this->backend->anon_function($foo); // call my personal function inside the controller

how I can do this when I loaded the controllers from AltoRouter?

  1. How I can perform an Ajax call from javascript?

the good thing of the route is this, call a function inside the controller from javascript, in the past with CodeIgniter I use:

$('#login-form').submit(function(event)
        {

            var postUrl = GlobalVariables.baseUrl + 'user/ajax_check_login';
            var postData =
            {
                'username': $('#username').val(),
                'password': $('#password').val()
            };

            $('.alert').addClass('hidden');

            $.post(postUrl, postData, function(response)
            {

so how you can see I call ajax_check_login available in the user controller.

So, someone could help me to understand better all this steps? I'm new on route, so I need very an help to understand this..

Sevengames Xoom
  • 312
  • 1
  • 6
  • 18

0 Answers0