简体   繁体   English

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

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

I want to redirect to admin_dashboard page in ajax.I call a function in button tag and want to redirect to next page in success response.value gets deleted perfectly but my problem is "Deleted Successfully" message is not returned and not redirect to admin_dashboard.php page. 我想重定向到ajax中的admin_dashboard页面。我在button标签中调用一个函数,并希望成功响应中重定向到下一页。value被完美删除,但我的问题是“未成功删除”消息没有返回,也没有重定向到admin_dashboard。 php页面。 instaed of '1' in function I used dynamic valued.for sample I used '1' myFunction(1).I caught an error in console. 我在函数中使用动态值设置为'1'。对于示例,我使用了'1'myFunction(1)。在控制台中发现错误。 在此处输入图片说明

HTML 的HTML

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

Script 脚本

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';
                }
            });
        }
    }
}

my php query page 我的php查询页面

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

Try below code in your php script: 在您的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