Welcome Guest, Not a member yet? Register   Sign In
ajax call to controller function outside root
#1

hi all

my application folder sits about the root
how can i call a controller function from ajax ?

Code:
$('#editabout').click(function() {
  
          

  $.ajax({
    type: 'get',
    url: '../application/controllers/auth_public/editabout',
    dataType: 'html',
    success: function (html) {
    
      $('#testdiv').html(html);
    }
  });
});

thanks
Reply
#2

The url you use is exactly like a normal link url, index.php will pick it up and convert it to wherever you application root is or follow any routing rules etc

PHP Code:
url'<?php echo site_url('auth_public/editabout'); ?>'

Alternatively you can hard code it in if your js is not contained in a view. Or you can set your base_url in a data attribute somewhere are read it in.
Reply
#3

(10-13-2016, 11:19 AM)PaulD Wrote: The url you use is exactly like a normal link url, index.php will pick it up and convert it to wherever you application root is or follow any routing rules etc

PHP Code:
url'<?php echo site_url('auth_public/editabout'); ?>'

Alternatively you can hard code it in if your js is not contained in a view. Or you can set your base_url in a data attribute somewhere are read it in.

you are a genius thanks

is it goot to put in root to hide 'auth_public'

$route['editabout'] = 'auth_public/editabout';
Reply




Theme © iAndrew 2016 - Forum software by © MyBB