douhua1760 2014-02-25 13:25
浏览 51
已采纳

可自定义的jquery警报框的麻烦

I am trying to get it so a alert box shows up after a query to the database has been made and the user has been headered back to a page on my website with a js alert box telling them success or something went wrong.

I found a jquery script but I just cant seem to get it to work/run when required. Below are 2 snippets of code from 2 pages. 1 page is the index and the other is the php/MySQL process.

Below is the code on my index page

<html>
<head>
<meta charset="UTF-8">
<title>........</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">


/////////////////////////////BELOW IS THE CCS INCLUDE FOR THE ALERT
<link rel="stylesheet" href="jquery/jquery-alerts.css">

/////////////////////////////BELOW IS THE JQUERY INCLUDE FOR THE ALERT
<script src="jquery/jquery-alerts.js"></script>

</head>
<body>

<div id="pageMiddle">

//////////////////This is the $_SEESION ARRAY CONTAINING THE ALERT TRIGGER
<?php
if(isset($_SESSION['errors']['error5301']) && $_SESSION['errors']['error5301'] == 1) { ?>
<script>
alert = function(message, title, callback){
$.alerts.alert(message, title, callback); };
</script>
<?php } ?>

THIS IS JUST CONTENT ON THE WEBSITE...................

</div>

//////////////THIS IS TO UNSET THE ERROR $_SEESION
<?php
if(isset($_SESSION['errors']))
{
unset($_SESSION['errors']);
}
?>

</body>
</html>

Below is the code on my PHP/MySQL process page after the process has taken place. this is directly after the query and within the same set of { } as the query. The header works fine.

header("location: index.php");
$_SESSION['errors']['error5301'] = 1;
session_write_close();
exit();

Below is the website I got the jquery from and the alert box I am trying to sort out is one at the top of the page

http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

Thank you for your time and I look forward to your help.

  • 写回答

1条回答 默认 最新

  • doutuan9357 2014-02-25 13:47
    关注

    may be I think you havent called the function.. just put

    <?php
    if(isset($_SESSION['errors']['error5301']) && $_SESSION['errors']['error5301'] == 1) { ?>
    <script>
     $.alerts.alert(message, title, callback);
    </script>
    <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私