gpt4 book ai didi

jquery - 使用jquery插件提交表单

转载 作者:行者123 更新时间:2023-12-01 04:58:58 25 4
gpt4 key购买 nike

我正在尝试使用 jquery 提交表单。我正在使用 Bootstrap 模式窗口。这是js fiddle 。我错过了什么吗?非常感谢

更新:我正在尝试使用ajax提交表单。我也尝试过,但运气不佳。

$('#comment_form').on('submit', function(){

$.post("/yourReceivingPage", $(this).serialize(), function(){

// Hide the modal
$("#my-modal").modal('hide');

});

// Stop the normal form submission
return false;
});

最佳答案

您引用了错误的元素,我为您提供了一个工作示例,请检查并告诉我它是否适合您:

$(document).ready(function() {
$('#comment-form-submit').click(function() {
$('#comment_form').submit();
alert('Handler for .submit() called.');
return false;
});
});​

jsFiddle Working Demo

对于 AJAX 解决方案,您需要引用熟悉且已经讨论过的问题:

jquery serialize and $.post

编辑:引用您关于如何提取可点击链接的ID的问题,此代码将为您完成:

 $(document).ready(function() {
$(".comments.no").mouseover(function() {
myDivsId = this.id; // as you mouse over on the link it will be stored in Global Var and then transferred anywhere you wish.
});
$('#comment-form-submit').click(function() {
$('#comment_form').submit();
alert('Handler for .submit() called + div\'s ID = ' + myDivsId);
return false;
});

});​

jsFiddle live demo

关于jquery - 使用jquery插件提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11973849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com