1

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.

Kuba
  • 1,415
  • 1
  • 18
  • 29

1 Answers1

0

sorry.. you can use this to change URL without load the page :

history.pushState({},null,'http://example-new-url.com');
Rifai
  • 194
  • 11
  • So, how it's done here: http://www.josephaavoue.com ? Go to page Archives or Contact. It's XMLHttpRequest and link not conatins hash :( – Kuba Aug 21 '15 at 13:36
  • I found one that may be will help you : http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page – Rifai Aug 21 '15 at 14:12