我的应用程序上有一个按钮,当用户点击它时,我希望重新加载页面。这是我的按钮:
<button type="button" class="btn btn-success-outline add_sol">Ajouter</button>
它调用了一个javascript函数:
$(function() {
$(".add_sol").click(function(){
var e = document.getElementById("select_sols");
var sol = e.options[e.selectedIndex].value;
var string = window.location.pathname+"_ajouter_sol"+window.location.search+"&id_sol="+sol;
alert(string); //The alert displays the right adress
self.location.href(string);
});
});
我使用string
变量发出警报,它会显示我想要的内容。但我不知道为什么self.location.href
不起作用。
答案 0 :(得分:1)
尝试window.location.href
- 应该完美运作
答案 1 :(得分:0)
使用location.reload();
可以刷新页面
或window.location = string;
进行重定向