dsfdsf21312 2014-07-03 01:05
浏览 27

重定向并不总是使用JQuery UI对话框

I am having some issues getting the jquery ui dialog redirecting always. When I click a delete link it asks if you are sure. If you click the delete button it should be redirected. THe problem is it doesnt always redirect the first time. It usually only works after you click the dialog window delete the second time. Does anyone know why this might happen? I have tried using the redirect in multiple places including after the query happens and before and after the delete query closes.

Page where dialog redirects(at bottom);

<a href="#" class="delete">Delete</a>

<script>
    var id = "";
    //run function after jquery dialong confirm
    //step 1 - the action
    $(".delete").click(function(e) {
        e.preventDefault();
        id = $(this).parent().attr('id');
        //console.log(id); // check you get it first
        $('#dialog').dialog('open');
    });
    //step 2 - the dialog modal
    $("#dialog").dialog({
        resizable: true,
        height: 100,
        modal: true,
        autoOpen: false,
        buttons: {
            "Delete": function() {
                //console.log(id + " made it to dialog"); // make sure our id makes it this far
                deleteUser(id); // run delete photo function
                window.location.href = "http://www.speechvive.com/adminSLP.php";
                $(this).dialog("close");

            },
            Cancel: function() {
                $(this).dialog("close");
            }
        }
    });
    //step 3 - php function
    function deleteUser(user_id) {
        //console.log(user_id + " made it to function"); // make sure our id makes it this far
        $.ajax({
            type: "POST",
            url: "/adminSLP.php#delete",
            data: {user_id: user_id}
        }).done(function(msg) {
            console.log(msg);
            //no message bc we did a fadeOut
            //var msg would show any errors from our php file
        });
    }
    ;
</script>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?