简体   繁体   English

PHP / AJAX将只提交一次表单结果。 第一次点击有效,第二次空白

[英]PHP / AJAX will only submit results of form once. First click works, second is blank

I'm getting some very odd behavior and I can't figure it out. 我有一些非常奇怪的行为,我无法弄清楚。

I've modified a piece of code from Bright Cherry [http://bit.ly/fmhcbu] and I'm basically just trying to change the value of a mySQL row from 0 to 1 or vice versa and refresh the results onscreen. 我已经修改了Bright Cherry [http://bit.ly/fmhcbu]的一段代码,而我基本上只是想将mySQL行的值从0更改为1,反之亦然,然后在屏幕上刷新结果。

VIEW PAGE HERE 在这里查看页面

When you click the submit button, the record is updated in the database and the page auto refreshes correctly. 当您单击提交按钮时,记录将在数据库中更新,并且页面会自动正确刷新。 But, when you click a second button, nothing happens. 但是,当您单击第二个按钮时,什么也没有发生。

Has anyone run in to this issue before? 以前有人遇到过这个问题吗? Thanks in advance! 提前致谢!

you need to re-run the jQuery ajaxForm code after each reload. 您需要在每次重新加载后重新运行jQuery ajaxForm代码。

update the code: 更新代码:

<script type="text/javascript">
  function makeAjaxForm(){
    $('#myForm').ajaxForm({
      target: '#showdata',
      success: function() {
        $('#showdata').fadeIn('slow');
        makeAjaxForm();
      }
    });
  }
  $(document).ready(function() {
    makeAjaxForm();
  });
  </script>

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

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