当我提交表单以在我的页面上发表评论时,页面会显示数据数组,而不仅仅是显示评论淡入的页面。
这是我点击提交按钮后在浏览器中看到的内容(记录插入正常):
{"streamid":1567,"cm":{"id":"0","avatar":"uploads\/30-av.jpg","name":"Mike<\/a>","content":"blah blah blah","time":"some seconds ago"}}
PHP
$action = $_GET['action'];
if ($action == 'blasting') {
$blast = input($_POST['blast']);
if ($blast AND strlen($blast) > 1) {
$stm = $_DB->prepare('insert into wl_activity (user_id, action, posted_on, data) values (?, ?, ?, ?)');
$stm->execute(array($_USER->get_user_id(), 'blast', time(), $blast));
}
echo json_encode($array);
}
我的表格代码
<script type="text/javascript" src="js/ajaxupload.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/newsfeed.js"></script>
<form method="post" action="index.php?cmd=ajax&action=blasting" id="blast-form">
<textarea class="form_input" id="blastbox" name="blast" style="width:90%" ></textarea>
<input type="submit" id="blastbtn" value="Post" class="form_submit" />
<div id="ajax-feed"></div>
<?php $general = array(); ?>
<?php
foreach ($feeds as $f) {
if ($f['action'] == 'blast')
array_push($general, 'blast');
//unset($general[count($general)-1]);
else
array_push($general, 'normal');
}
?>
这是我的 jquery.form.js http://pastebin.com/MP3uVdcP 这是我的 newsfeed.js http://pastebin.com/ymSNjXJR