php - Ajax access into codeigniter controller


I have some problems using my JQuery Ajax methods my controller. Seems that it can´t find the controller, and I can´t seem to get rid of the index.php.

It works fine on my MAMP localhost, but when I uploaded the project til the webhost, apache 2.2.16 (debian). My ajax can't access the controller.

I keep getting this error:

 <title>404 Not Found</title>
 <h1>Not Found</h1>
 <p>The requested URL /home/stud/xxxxx/public_html/revy/index.php/$ was not found on this
  server.    </p

Ajax, can access and load from files located outside the codeigniter application folder.

This is the error message I get,

My code looks like this:


public function loggInn_Ajax(){
    $response = '';
        $this -> form_validation -> set_rules('brukernavn', 'Brukernavn',  
        $this -> form_validation -> set_rules('passord', 'Passord', 'required');


            $brukernavn = $this->input->post('brukernavn');
            $passord = $this->input->post('passord');
            $aktiveringskode = $this->input->post('aktiveringskode');

            if($aktiveringskode != ''){
                $aktivering = $this->bitauth->activate($aktiveringskode);

                if($aktiveringskode == FALSE){
                    $response = 'Feil aktiveringskode, om du har tastet 
                  riktigkode.Ta kontakt med systemansvarlig.';

            $remember_me = '';

            $res = $this->bitauth->login($brukernavn, $passord, $remember_me);

            if($res === 'inaktiv'){
                $response = 'inaktiv';
            } else if($res == TRUE){
                $response = 'ok';
                $response = $this->bitauth->get_error();

            $response = validation_errors();
      echo $response;


function loggInn() { 

brukernavn = $('#brukernavn').val();
passord = $('#passord').val();
husk_meg = $('#husk_meg').val();
aktiveringskode = $('#aktiveringskode').val();

return false;


  function sendLoggInnnData(){

var logginn = {
    'brukernavn': brukernavn,
    'passord': passord,
    'husk_meg': husk_meg,
    'aktiveringskode': aktiveringskode,
    'ajax': 1

    url : 'MetodeKontroller/loggInn_Ajax',
    type: 'POST',
    data: logginn,
    success:function(response) {
        if(response == 'inaktiv'){
            $('#aktiveringsfelt').html("<input name='aktiveringskode' 
       id='aktiveringskode' class='input-block-level' type='text' value='' required='required' 
      placeholder='Aktiveringskode' autofocus='autofocus' onblur='validerInput(this)'    
      maxlength='6' min='6'>");

        }else if(response == 'ok'){
            window.location.href = "SideKontroller";




$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/ProjectFolderName';

Try this

var url = '<?php echo base_url();?>';

and in ajax use this:


People are also looking for solutions to the problem: php - Internationalisation language switch?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.