使用 javascript 重定向到相对于根路径的路径
Redirect to a path relative to root path using javascript
我正在做一个项目,我有一个表单来添加一个线程,如下所示:
共享按钮验证线程并将线程保存到数据库:
$('.share-thread').click(function() {
// Validations
let data = {
'_token':csrf,
'subject': $('#subject').val(),
'category_id': $('#category').val(),
'content':simplemde.value(),
'thread_type': $('#thread_type').val()
};
$.ajax({
type: 'post',
data: data,
url: '/thread',
success: function(response) {
window.location.href = "/" + response;
}
});
});
在控制器中,我 return 路径如下:/general/discussions
现在我想要的是如何在本地环境的情况下将此路径附加到根路径我想要这样的东西:
127.0.0.1/general/discussions
生产情况下:
www.domain.com/general/discussions
谢谢!
我正在做一个项目,我有一个表单来添加一个线程,如下所示:
共享按钮验证线程并将线程保存到数据库:
$('.share-thread').click(function() {
// Validations
let data = {
'_token':csrf,
'subject': $('#subject').val(),
'category_id': $('#category').val(),
'content':simplemde.value(),
'thread_type': $('#thread_type').val()
};
$.ajax({
type: 'post',
data: data,
url: '/thread',
success: function(response) {
window.location.href = "/" + response;
}
});
});
在控制器中,我 return 路径如下:/general/discussions 现在我想要的是如何在本地环境的情况下将此路径附加到根路径我想要这样的东西:
127.0.0.1/general/discussions
生产情况下:
www.domain.com/general/discussions
谢谢!