我正在尝试使用 ajax 插入评论。除了 $_POST 一切正常。它似乎没有发布数据,因此表中的评论字段为空。其他工作正常,例如插入日期。我只有 ajax 有问题(php 没有问题)。
无论如何,这是我的代码:-
<head>
<script>
function su_post(id) {
$("#load_post").show(),
$("#post_submit").click(function() {
var c_post = $("#c_post").val();
var dataString = '&c_post=' + c_post;
$.ajax({
type: "POST",
url: '/script/post.php',
data: "id=post_script" + id,
cache: false,
success: function(){
$("#load_post").fadeOut();
}
})});
};
</script>
</head>
<body>
<form id="form_post" method="post" action="javascript:su_post(1)">
<label for="c_post">Post your updates/status</label>
<input type="text" name="c_post" id="c_post" />
<br /><br /><input type="submit" id="post_submit" value="Post" />
</form>
</body>
编辑:因为你可能不理解我;获取您在输入框中键入的值并将该值发布或发送到 post.php 时出现问题。当我输入data: {id: post_script + id, c_post: c_post}
时,代码似乎根本没有加载 php 文件。(卡在发帖上-> http://prntscr.com/10dmjt)
提前谢谢你:)