如何从Ajax回调提交表单 [英] How to submit a FORM from ajax callback
本文介绍了如何从Ajax回调提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我了解ajax的过程中,我遇到了这个问题,我不知道如何首先通过在我的表中请求数据来解决这个问题
through my journey on understanding ajax i came up with this problem and i don't know how to solve it first im requesting for datas in my table
load_data();
function load_data(page)
{
$.ajax({
url:"data.php",
method:"POST",
data:{page:page},
success:function(data){
$('#result').html(data);
},
error:function(exception){alert('Exeption:'+exception);}
})
}
这只是要输出的表格
<table>
<thead>
<tr>
<th>name</th>
<th>details</th>
<th>price</th>
<th></th>
</tr>
</thead>
<tbody id = "result">
这是网络"标签中的输出
and this is the output from network tab
响应中有一个按钮,我试图使用此jquery激活它以提交其表单,但这不起作用
there's a button from the response i tried to activate it using this jquery to submit its form but this doesn't work
$(document).on('click', '#add_details', function(){
$(this).parents("form").submit();
});
推荐答案
将ID添加到您需要通过单击按钮提交的表单中,例如
add id to the form you need to submit with button click like
<form id="myForm1">
//Other Code Here
并使用您的按钮,只需使用您添加的ID
and with your button just Use the id you added
$(document).on('click', '#add_details', function(){
$("#myForm1").submit();
});
这篇关于如何从Ajax回调提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文