van_folmert van_folmert - 7 months ago 25
Javascript Question

403 Access Forbidden when directly accessing a page using base_url()

I'm getting a 403 error when trying to access a page via


$("form").submit(function( event ) {"GET","<?=base_url('application/views/pages/search_sql.php'); ?>",true);


I could load the page
by straightforward"GET","search_sql",true);
but then it doesn't load the script directly - instead it is handled by controller and loaded with other views which are unwanted in this case.

Answer Source

You are using CodeIgniter so why are you trying to load anything directly?

Call the page as you would normally and add a controller method to do what is required in this situation. So:

Assuming you have a controller called 'Search' create a method called something relevant lets say 'special_case' and call that with any parameters it requires like so


class Search extends Controller {

    function index()
        // I assume this is what it is currently doing

    function special_case()
        // Make this do whatever is required in this case.

Then call it from your Javascript using the standard CodeIgniter controller/method/param1/param2 ...... mechanism.