繁体   English   中英

如何在ajax成功块中重定向到下一页

[英]how to redirect to next page in ajax success block

我想重定向到ajax中的admin_dashboard页面。我在button标签中调用一个函数,并希望成功响应中重定向到下一页。value被完美删除,但我的问题是“未成功删除”消息没有返回,也没有重定向到admin_dashboard。 php页面。 我在函数中使用动态值设置为'1'。对于示例,我使用了'1'myFunction(1)。在控制台中发现错误。 在此处输入图片说明

的HTML

<button style="margin-left:10px;" name="delete" onclick="myFunction(1);">Delete</button>

脚本

function myFunction(del) {

    var rmvfile = del;

    if (confirm("Are you sure you want to Delete the file?") == true) {
        if (del != '') {
            $.ajax({
                type: 'post',
                url: 'query9.php',
                data: {
                    rmvfile: rmvfile
                },
                success: function(msg) {
                    window.location.href = 'admin_dashboard.php';
                }
            });
        }
    }
}

我的php查询页面

 <?php
 include "config.php";
 $s=$_POST['rmvfile'];  
 $del="delete from requirement where req_id='$s'";
 if($del1=mysql_query($del))
 {
     echo 'Deleted Successfully';
 }

在您的php脚本中尝试以下代码:

<?php
 include "config.php";
 $s=$_POST['rmvfile'];  
 $del="delete from requirement where req_id='$s'";
 if( mysql_query($del) )
{
echo 'Deleted Successfully';
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM