404 how make a rote |
I send ajax to server
$.ajax({ type: 'POST', dataType:'json', url: '/functions_ajax/check_all_Ukraine', There is a server side class Functions_ajax extends CI_Controller { public function __construct() { parent:: __construct(); $this->load->helper('url'); require('server/FirePHP.class.php'); $this->load->model('cities_model'); $firephp = FirePHP::getInstance(true); $firephp -> fb("hello world! i'm warning you!",FirePHP::WARN); } public function check_all_Ukraine(){ $data=$this->cities_model->get(); if($data){ echo json_encode($data); } else{ echo json_encode(NULL); } } } And this is A route $route['functions_ajax/check_all_Ukraine'] = 'functions_ajax/check_all_Ukraine'; But I still have 404 error
Use this for the url:
PHP Code: url: '<?php echo site_url();?>functions_ajax/check_all_Ukraine',
Firstly define base_url in header.
<script type="text/javascript"> var site_url = '<?php echo site_url(); ?>'; var base_url = site_url; var siteurl = site_url; </script> after that you can use url something like that where you want in whole project files. $.ajax({ type: 'POST', dataType:'json', url: siteurl+'functions_ajax/check_all_Ukraine',
@ XtreemDeveloper
Note: base_url() and site_url() are not the same thing. base_url() = http://www.yoursite.com site_url() = http://www.yoursite.com/index.php What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Every time I log onto this forum I find something helpful that I didn't even know I needed... thanks XtremeDeveloper and InsiteFX!
|
Welcome Guest, Not a member yet? Register Sign In |