当用户单击按钮时,我会显示一个对话框以确认它的操作,然后在服务器上执行删除操作
@RequestMapping(method = RequestMethod.GET, value = "/secure/admin/deleteuser/{username}")
public String deleteUser(Model model, @PathVariable("username") String username, BindingResult result) {
...
}
$("#deleteUserConfirm").dialog({
autoOpen: false,
resizable: false,
height: 180,
modal: true,
buttons: {
"Delete user": function() {
var username = $(this).data('username');
var url = "/secure/admin/deleteuser/" + username;
//server call to delete this user
$.ajax({
type: "GET",
url: url
}).done(function() {
alert("second success");
}).fail(function() {
alert("error");
}).always(function() {
alert("finished");
});
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
我从不去服务器...我看到第二个成功警报和完成警报我没有任何错误
我在服务器上试过
@RequestMapping(method = RequestMethod.GET, value = "/secure/admin/deleteuser")
public String deleteUser(Model model, @RequestParam("username") String username, BindingResult result) {
}
在js中
$.ajax({
type: "GET",
url: "/secure/admin/deleteuser",
data: {username: "RenewalRate2"}
}).done(function() {
alert("second success");
}).fail(function() {
alert("error");
}).always(function() {
alert("finished");
});
我在 chrome 中看到一个请求:
`http://localhost:8084/secure/admin/deleteuser?username=RenewalRate2`
在它的状态下它是 200 ......但服务器上没有做任何事情......