1

When I load a Partial View with some unobtrusive AJAX I also need the URL to change accordingly.

It would be okay if I had to do the work in the jQuery's done() callback.

But it's not possible right, wihtout loading something new. So the only choise I have is to load a View?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
radbyx
  • 9,352
  • 21
  • 84
  • 127

1 Answers1

2
$.ajax({
    //some jquery ajax call properties
    success: function(){
        location.hash = 'your_unique_value';
    }
})

or use history api window.history.pushState('page2', 'Title', '/page2.php');

Docs

aleha_84
  • 8,309
  • 2
  • 38
  • 46
  • Can you add a ";" after the string? Thanks i didn't knew that. What does pushState? Can you edit an example please? – radbyx Feb 05 '15 at 14:40
  • 1
    So the answer to the question is no right? If so you have provided the some fine and close alternatives i can consider and then accept your answer. – radbyx Feb 05 '15 at 14:45
  • you ask how to change url without reloading page, here is 2 variants. – aleha_84 Feb 05 '15 at 14:46
  • 1
    pushstate is actually really nice. I prefer that over the hash hack alot. Really a nice answer. – radbyx Feb 10 '15 at 07:55