我的 AJAX 帖子表单似乎不起作用。似乎没有数据通过。知道为什么吗?
形式
<label for="title">Please give your idea a title</label>
<br />
<input type="text" id="title" name="title" />
</p>
<p>
<label for="message">Please provide details of your idea</label>
<br>
<input type="text" id="message" name="message" />
</p>
<input type="button" id="sendmessage" value="Post"></input>
jQuery
$.post("assets/post.php", {
title: $("#title").val(),
message: $("#message").val()
}, function (data) {
alert(data);
$chat.prepend('<span class="idea"><strong style="color: #0081C5">' + $messageTitle.val() + '</strong>' + ' - ' + $messageBox.val() + ' ' + '<a class="delete" href="#">[Delete]</a>' + '</span>')
$messageTitle.val('');
$messageBox.val('');
$('#post_confirm').show().html('<br><span class="confirm_msg">Message posted successfully</span>');
$('#chat').height($(window).height() - $('.header').height() - $('.user').height());
setTimeout(function () {
$('#post_confirm').fadeOut('slow');
$('#chat').height($chatHeight_user);
}, 1000);
});
post.php
<?php include("config.php");
$title = $_POST["title"];
$message = $_POST["message"];
$sql = "INSERT INTO idea (title,message) VALUES (:title,:message)";
$q = $pdo->prepare($sql);
$q->execute(array(':title'=>$title,':message'=>$message));
?>
我收到以下错误消息: