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:
Instead of going to the controller /index.php/admin/getUserSt atusInfo
it's calling (/index.php/admin/productI nventory/g etUserStat usInfo 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?
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');
}
});
Instead of going to the controller /index.php/admin/getUserSt
it's calling (/index.php/admin/productI
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome.
ASKER