I have installed CodeIgniter in localhost/CodeIgniter and written the same path in config file: $config['base_url'] = 'http://localhost/CodeIgniter/'
. Now I need to send AJAX request to http://localhost/CodeIgniter/register/user_register
It's not working when I use url /register/user_register
in ajax request but works when I use /CodeIgniter/register/user_register
.
I don't want to use /CodeIgniter/
directory every time as I am working on local host because when I will deliver the project it will definitely not be in CodeIgniter directory. So I would have to change this every where I have sent the ajax request.
I'm looking for a way which CodeIgniter provide to avoid using this directory every time and define it once so that I can change it easily when delivering the project.
Not working this way
$.ajax({
url : "/register/user_register",
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function(data){
alert(data);
}
});
But working this way
$.ajax({
url : "/CodeIgniter/register/user_register",
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function(data){
alert(data);
}
});