加载局部视图并同时更改 URL
Loading a Partial View and changing the URL at the same time
当我加载带有一些不显眼 AJAX 的局部视图时,我还需要 URL 进行相应的更改。
如果我必须在 jQuery 的 done() callback
中完成工作也没关系。
但这是不可能的,不加载新的东西。所以我唯一的选择就是加载视图?
$.ajax({
//some jquery ajax call properties
success: function(){
location.hash = 'your_unique_value';
}
})
或使用历史记录apiwindow.history.pushState('page2', 'Title', '/page2.php');
当我加载带有一些不显眼 AJAX 的局部视图时,我还需要 URL 进行相应的更改。
如果我必须在 jQuery 的 done() callback
中完成工作也没关系。
但这是不可能的,不加载新的东西。所以我唯一的选择就是加载视图?
$.ajax({
//some jquery ajax call properties
success: function(){
location.hash = 'your_unique_value';
}
})
或使用历史记录apiwindow.history.pushState('page2', 'Title', '/page2.php');