html
<form class="new_comment" id="new_comment">
<div class="comment-text">
<textarea maxlength="2000" placeholder="写下你的评论…" class="mousetrap" id="reply_content" name="reply_content"></textarea>
<div>
<input type="button" name="commit" id="commit" value="发 表" class="btn btn-info">
<span id="reply">回复帖子</span></div>
</div>
</form>
js
$('#commit').on('click', function () {
$('#new_comment').ajaxSubmit({
type: 'post',
url: "test.php",
success: function (data) {
//data存放需要返回的数据
}
});
});
要引入jquery.js,jquery.form.js
本文介绍了一个简单的Ajax表单提交示例,通过jQuery实现表单内容的异步发送,包括HTML表单元素和相应的JavaScript代码。示例中演示了如何在用户点击按钮后触发Ajax请求,并将表单数据发送到服务器。
7万+

被折叠的 条评论
为什么被折叠?



