This is my first CI project so forgive me.
I simply can’t hit a method with an AJAX call. It keeps coming up as a 404 in Web Inspector.
I have a controller called “home.php”. It’s working. I can land on my home page.
Then I have this AJAX call firing on a hover event
function showDataWindow(){
// i might switch this to data attr, but for now item IDs are contained in class
var thisClass = $(this).attr('class');
var thisIDpos = thisClass.indexOf("id-")+3;
var thisID = thisClass.substr(thisIDpos, 3);
alert(thisID); // alerting correctly
$.post('getMoreInfo', { ID: thisID},
function(data) {
.. act on data
I simply can find the method I am calling – getMoreInfo. Always 404.
I have a home.php class in my controllers and its set as my default, and it works because I am landing on my home page and getting the index. But in that home controller is also my getMoreInfo function…
public function getMoreInfo()
{
$ID = $_POST['ID'];
$this->load->model('Artist_model');
$assocReturned = $this->Artist_model->get_more_info($ID);
echo json_encode($assocReturned);
}
And I feel like there is a tiny MC Hammer guarding that function. “You can’t touch this”. He mocks me in his little parachute pants and minuscule fade.
I think it must be how I am doing my URI in the Jquery AJAX post? I have index re-writing in my htaccess (which I am kind of foggy on exactly)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
But I have tried just about every URI permutation in that AJAX call
www.mySite.com/index.php/home/getMoreInfo
index.php/home/getMoreInfo
index.php/getMoreInfo
/home/getMoreInfo
home/getMoreInfo
/getMoreInfo
getMoreInfo
!
And none have worked.
What you have to call depends on how your router is configured.
Default call would be
/home/getMoreInfo, but could be changed if you have reconfigured your router. Reference: http://codeigniter.com/user_guide/general/routing.html