如何在使用PHP将数据插入MySQL表后显示jquery msgBox
我想在数据已经插入MySQl表时显示一个消息框。我的代码如下:如何在使用PHP将数据插入MySQL表后显示jquery msgBox,php,jquery,mysql,msgbox,Php,Jquery,Mysql,Msgbox,我想在数据已经插入MySQl表时显示一个消息框。我的代码如下: if($insert_query) { <script type='text/javascript'> $.msgBox('Data Added'); window.location = 'bentry.php'; </script> } if($insert\u查询) { $.msgBox(“添加数据”); window.location='
if($insert_query)
{
<script type='text/javascript'>
$.msgBox('Data Added');
window.location = 'bentry.php';
</script>
}
if($insert\u查询)
{
$.msgBox(“添加数据”);
window.location='bentry.php';
}
但未显示警报。如何解决这个问题。原因是
window.location = 'bentry.php';
$.msgBox(“添加数据”)代码>已加载,但重定向脚本已导航到另一页。请尝试以下操作:
echo "<script type='text/javascript'>
$.msgBox('Data Added');
window.location = 'bentry.php';
</script> "
echo”
$.msgBox(“添加数据”);
window.location='bentry.php';
"
或
if($insert\u查询)
{ ?>
$.msgBox(“添加数据”);
window.location='bentry.php';
if($insert\u查询)
{
$.msgBox(“添加数据”);
setTimeout(函数(){window.location='bentry.php';},1000);
}
即使我删除window.location='bentry.php';它也不会显示msgbox。您是否检查了页面中包含的msgbox相关库您使用了哪个库,我包含的库的名称是什么?您可以试试这个,$(function(){$.msgbox('Data Added');});
您的第二个选项是我的原始代码,它不起作用。.问题是Jquery.msBOx中给出的演示示例。当有人单击时,它显示msgbox,但我希望在某些条件为真时显示它。@jayantKumarnath 1.否。您没有右大括号/右大括号。这使得它有所不同。2.条件为真吗?是否执行正常的alert而不是msg框来检查解决方案是否有效。如果有效,则说明msgbox库存在问题。当我使用alert(“添加数据”)时;它可以工作,但当试图用msgbox替换它时,它不起作用。因此,目前我发出警报。但我想知道问题出在哪里。@JayantaKumarNath正是我所想的。你包括了msgbox所需的所有库吗?你调用的函数正确吗?是的,我包括了所有需要的库…但我确信c函数的调用产生了问题…就像我添加数据时一样..数据被插入到表中,但msgbox没有显示任何警报..请先更正代码。上面提到的代码应该会生成PHP错误。
if($insert_query)
{ ?>
<script type='text/javascript'>
$.msgBox('Data Added');
window.location = 'bentry.php';
</script>
<?php } ?>
if($insert_query)
{
<script type='text/javascript'>
$.msgBox('Data Added');
setTimeout(function(){window.location = 'bentry.php';},1000);
</script>
}