Link to home
Start Free TrialLog in
Avatar of tf2012
tf2012

asked on

codeIgniter ajax post path question

I have a function in a script file (myScripts.js).  The function uses ajax to contact the controller to get the user status info.

here is a sample url of a page that may use the script:

http://www.mysite.com/index.php/admin/productInventory/79323 (works great, show the page, everyone is happy)

but the problem arises when this fires on document ready:
$.ajax({
        url     : 'getUserStatusInfo',
        type    : 'POST',
        data    : '',
        success : function(response){
                alert('hey it worked');
        },
         error : function(response){
                alert('hey it didnt work');
         }
 });

Open in new window


Instead of going to the controller /index.php/admin/getUserStatusInfo

it's calling (/index.php/admin/productInventory/getUserStatusInfo and shouldn't be.  

In code igniter I can simple use base_url to solve the issue.  But how do I do this if the ajax call is defined in a javascript file and not in PHP?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tf2012
tf2012

ASKER

thanks
You are welcome.