0

ユーザーがボタンをクリックすると、そのアクションを確認するダイアログ ボックスが表示され、サーバー上で削除を行った後

@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");
            }
        }
    });

サーバーにアクセスすることはありません... 2 番目の成功アラートと完了アラートが表示されます。エラーはありません

サーバーでやってみた

@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");
                });

私はクロームで次へのリクエストを見ます:

`http://localhost:8084/secure/admin/deleteuser?username=RenewalRate2`

そのステータスでは200です...しかし、サーバーでは何も行われていません.....

4

3 に答える 3

0

コントローラーを変えました

@RequestMapping(method = RequestMethod.GET, value = "/secure/admin/deleteuser")
@ResponseBody
public void deleteUser(@RequestParam("username") String userName) {
}

そしてその作業ファイル

于 2013-10-29T18:06:04.447 に答える
0

確認ダイアログを使用します。

var status = confirm("Are you sure??");
if(status == true)
{
   //Make an ajax call and delete
}
else
{
  //Do nothing.
}
于 2013-10-29T05:52:15.870 に答える