我的comment.php有这个:
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
$('#reset_form').click(function() {
$('#name,#comment').val('');
});
$('#submit').click(function() {
var name = $('#name').val();
var comment = $('#comment').val();
$.ajax({
url: '../forms/comment_ajax.php?id=<?php echo $_GET['id']; ?>',
data: { form_name: name, form_comment: comment },
success: function(data) {
$('#new_comment').append(data);
$(document).trigger('close.facebox');
$('#new_comment').effect("bounce", { direction:'down', times:5 }, 300);
$('html,body').animate({scrollTop:0}, 2000, "easeOutQuart");
return false;
}
});
});
});
</script>
Name: <br />
<input type="text" id="name" class="userpass" maxlength="15"/><br /><br />
Comment: <br />
<textarea id="comment" rows="6" cols="75"></textarea><br /><br />
<input type="submit" name="submit class="button" value="Comment" />
<input type="reset" name="submit" value="Reset"/>
然后这是我的 AJAX:
<?php
require_once('../blog/inc/config.php');
$form_name = $_GET['form_name'];
$form_comment = htmlspecialchars($_GET['form_comment']);
$date = date('M jS Y | g:i a T');
$ip = $_SERVER['REMOTE_ADDR'];
if($form_name == '') {
echo("<div class='alert alert-error-x'>Don't forget to enter your 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='article-body-new'>
<div class='user'><b>$form_name</b> <span>says:</span></div>
<div class='comments'>
$form_comment <br /><p></p><br />
<p style='font-size:12px;'>Posted on <b><font size='0.8em'>$date</font></b></p>
</div>
</div>";
}
?>
我在 facebox js 上工作,这就是它的样子:http ://screencloud.net/v/m9jR
但是,一旦您尝试发布,它就不会发布内容。我一直点击“评论”,但它不会执行。
我的完整 article.php 页面在这里: http: //pastebin.com/DCHGR1Ly
你们会碰巧知道我做错了什么吗?