我有一个关于这个淡出 div 的快速问题。我使用facebox,提交后,它显示一个错误,它会显示这个:
但是,在他们收到该消息后,我希望它消失。在我的提交表单的 AJAX 处理程序上,这是 PHP 代码:
<?php
require_once('....');
$form_name = $_GET['form_name'];
$form_comment = $_GET['form_comment'];
$date = date('Y-n-j');
$ip = $_SERVER['REMOTE_ADDR'];
if($form_name == '') {
echo("<div class='alert alert-error-x'>Don't forget to enter a name, as we need to identify who's commenting on this article!</div>");
} else if($form_comment == '') {
echo("<div class='alert alert-error-x'>Please do not leave the comment field blank, we want to know what you're saying!</div>");
} else {
mysql_query("INSERT INTO comment (id, articleid, name, comment, date, ip) VALUES (NULL,'{$_GET['id']}','{$form_name}','{$form_comment}','{$date}','{$ip}')");
// output comment
echo "<div class='alert alert-success-x'>Posted by <strong>$form_name</strong> on <strong>{$date}</strong>$form_comment</div>";
}
?>
这是 article.php 上将提交的内容的输出:
<?php
$amount_get = mysql_query("SELECT * FROM comment WHERE articleid='" . mysql_real_escape_string($_GET['id']) . "'"); $comments = mysql_num_rows($amount_get);
$grab = mysql_query("SELECT * FROM comment WHERE articleid='" . mysql_real_escape_string($_GET['id']) . "'");
if (mysql_num_rows($grab)==0) {
echo "<div class='alert alert-note-x'>Sorry, it looks like their are no comments to be displayed, check back later!</div>";
}
while($row = mysql_fetch_array($grab)){
?>
<div id="new_comment"></div>
<div class="article-comment">
Posted by <b><?php echo $row['name'] ?></b> on <b><?php echo $row['date'] ?></b>
<br />
<?php echo $row['comment'] ?>
</div>
<?php } ?>
</div>
</body>
</html>
现在我尝试在 core.js 文件中添加以下代码,该文件位于我的网站 krissales.com
$(window).bind("load", function() {
$('#new_comment').fadeOut(4000);
});
然而它没有用。如果您想测试演示,请访问:http ://www.krissales.com/#/media/30.This-is-a-new-article-for-Testing !
请问我做错了什么?
谢谢!