繁体   English   中英

使用.load()时,jQuery表单提交不起作用

[英]Jquery form submit not working when using .load()

我有一个php表单,当我直接打开它时可以正常工作。 提交按钮将根据需要将记录添加到几个表中(使用MySQL)。

但是,当我将页面加载到另一页面的div中时,单击“提交”按钮不会添加记录。

这是JS

$('.tab_content').hide();
$('ul.tabs li:first').addClass("active").show();
$('.tab_content:first').show();

$('ul.tabs li').click(function () {
    $('ul.tabs li').removeClass("active");
    $(this).addClass("active");
    $('.tab_content').hide();
    var activeTab = $(this).find("a").attr("href");
    $(activeTab).fadeIn(200, function () {
        $(this).load($(this).attr("id") + ".php?" + Math.random());
    });
            return false;
});

因此,例如,它是load example.php ,现在,如果该文件中的文件是某种提交形式,则该按钮将无法正常工作,例如使用html这样简单

<form id="history" method="post" action="some_action.php">
<input type="text" name="test" id="test">
<input type="submit" value="submit" name="submit">
</form>

感谢您的回答)

如果您正确获得href值。.然后:

使用$.ajax(); 而是尝试以下方法:

<input type="button" id="do_submit" value="submit" name="submit">

然后:

$("#do_submit").click(function(){
 $.ajax({
  type: "POST",
  url: yourURLvariable,
  success: function(data){
  $("#result_target").html(data);
}
 });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM