php - Getting error404 on Ajax in Codeigniter -


i have problem ajax code. i`m trying increase number inside span on click ajax, keep getting error in console - post localhost/slots/game/lines 404 (not found) . btw, use codeigniter.

here code :

php (controller)

 <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class game extends ci_controller {     function __construct()     {         parent::__construct();     }     function index(){     }     function win()     {         $this->session->set_userdata( array('win') => $win);         $win = $this->input->post('win');     }     function lines()     {         $this->session->set_userdata( array('lines') => $lines);         $lines = $this->input->post('lines');         echo $lines++;     }     function wager(){         $this->session->set_userdata( array('wager') => $wager);         $wager = $this->input->post('wager');     }    } ?>  

and here ajax -

function lines() { var lines = parseint($('#lines span').html()) + 1; $.ajax({         type: 'post',         url: base_url + 'game/lines',         data: { lines: lines },         success:function(response){             if(response <= 8){                 $('#lines span').html(response);                 return true;             }             else return false;         }  }); } 

and in html call lines function onclick.i`m using latest xampp virtual host.i have 1 custom route in ci -

$route['game/(:any)'] = "game/$1";
p.s. base_url defined in js variable.

as found out in comments problem url_rewrite. try this:

make file called .htaccess , place in root folder, index.php file (notice dot in front). write code:

rewriteengine on rewritecond $1 !^(index\.php|images|robots\.txt) rewriterule ^(.*)$ /index.php/$1 [l] 

in application/config/config.php index file option should empty empty like:

$config['index_page'] = ''; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -