Don P
Don P

Reputation: 63627

Codeigniter ajax gives 404 not found

I'm trying to use ajax with Codeigniter, but I'm getting a 404 (not found) error.

For ajax I do this:

    $.ajax({
        type: "POST",
        url: "/index.php/ajax/user-sign-up-via-email",
        data: {
            email: email,
            password: password
        }
    });

For my Routes.php I have this:

$route['ajax/user-sign-up-via-email'] = "UserSignUpViaEmailAjaxController";

Am I missing something specific to Codeigniter?

Is it related to first URL parameter being the controller, second parameter being the function to call within the controller?

Upvotes: 0

Views: 3896

Answers (2)

hellosheikh
hellosheikh

Reputation: 3015

i do this normally .. u can try this also

      url: "<?php echo site_url('customersController/addCustomer'); ?>",

Upvotes: 0

Bad Wolf
Bad Wolf

Reputation: 8349

As per comments:

Make sure that the controller you are calling (UserSignUpViaEmailAjaxController) has an index() function. Since you are remapping the uri directly to a controller without specifying a function it will default to the index() function and will 404 if it can't find one.

Upvotes: 3

Related Questions