I have a little trouble loading partial views by ajax. I used this schema:
config/constants.php
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
then each controller function, which need to be loaded by ajax contains:
if(IS_AJAX){
//action when AJAX request
$this->load->view("partial_view", $data);
}else{
//action when user open page directly in browser
$this->load->view('full_view',$data);
}
for e.g. when I'm on home page (http://example.com
) and i want to use Example controller and Edit action.
Now, if IS_AJAX is true my content loaded correctly, but url in browser is still the same http://example.com
.
else if IS_AJAX is false there is no problem. I've got url http://example.com/example/edit/params
How to change url for the AJAX requests to look like a standard CI url ?
P.S I don't want to use hash if it's not needed :/
Thanks in advance.