php - Ajax post to codeigniter controller giving 404, but making it to the controller? -
this working perfect me , team locally, once pull live server , try it, gives me 404 error still provides error response login function in controller. i've been trying figure out several hours no luck, , other posts haven't helped. i'm hoping it's stupidly simple i'm not seeing.
edit: important part post data doesn't sent on server, locally.
ajax call:
var username = $('#loginusername').val(); var password = $('#loginpassword').val(); var data = { "username": username, "password": password }; $.ajax({ type: "post", url: "<?php echo base_url(); ?>login", data: data, success: function(response) { //response code } }); controller function being called:
public function login() { $data = $_post; if(!$data) { //error code } else { //success code } } and if helps, here's .htaccess:
<ifmodule mod_rewrite.c> rewriteengine on rewritebase / #removes access system folder users. #additionally allow create system.php controller, #previously not have been possible. #'system' can replaced if have renamed system folder. rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ /index.php?/$1 [l] #when application folder isn't in system folder #this snippet prevents user access application folder #submitted by: fabdrol #rename 'application' applications folder name. rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ /index.php?/$1 [l] #checks see if user attempting access valid file, #such image or css document, if isn't true sends #request index.php rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l] </ifmodule> <ifmodule !mod_rewrite.c> errordocument 404 /index.php </ifmodule>
if running on localhost means may controller name writing having case sensitive problem. first check case sensitive problem try url: "<?php echo site_url('controllername/functionname'); ?>"
Comments
Post a Comment