有一个带有代码的html页面
<script>
$(document).ready(function(){
var currentID = $('#SelecUserForRemove').val();
console.log("currentID= "+currentID)
$("#testButton").click(function(){
$.ajax({
type: 'GET',
url: "/user/"+currentID,
success: function () {console.log("testButton")},
error: function () { alert("Не удалось удалить элемент") }
});
});
//работа с option для удаления элемента
$('#SelecUserForRemove').change(function() {
currentID = $(this).val();
console.log(("currentID= "+currentID))
});
});
</script>
路线文件说:
GET / controllers.UserController.index
GET/user/:id controllers.UserController.remove(id:Int)
删除方法:
def remove(id: Int)() = Action {
userService.removeUser(id)
println(userService.findAll().toString())
Redirect(routes.UserController.index())
}
请求离开并在服务器上进行处理,但 Redirect 方法不起作用, index 方法不起作用。为了查看更改,您需要手动刷新页面。如果在地址栏写/users/1,那么id=1的元素会被成功删除,并且会转换到index,我做错了什么?
Redirect
触发:处理程序应如何
$.ajax
将您重定向到另一个页面?