繁体   English   中英

使用AJAX重新加载PHP FORM

[英]Reloading PHP FORM using AJAX

在我的Web门户中,我有一个index.php页面,该页面具有<div>标记,其内容是使用AJAX获得的。 在此<div>标记处,调用页面index2.php index2.php页面上,应使用AJAX提交一种表单(无需刷新整个页面,只需刷新index2.php )。 提交后,应该再次调用index2.php但要使用来自表单的其他一些参数(通过POST )。

问题是因为发送了POST请求,但看起来<div>index2.php )的内容未更改。 这是代码:

index.php

 <div id="left_side">
       <h3>Toolbar</h3>
 </div>

  <div id="content">
      there will be refreshed index2.php
  </div>
  ......
   function doAjax() {

          var frm = $('#plotForm1');
          $.ajax({
              type: frm.attr('method'),
              url: frm.attr('action'),
              data: frm.serialize(),
              success: function (data) {

                            }
             });    
     }

index2.php

<form id="plotForm1" action="index2.php" onsubmit='doAjax(); return false;' method="post">
 ....
</form>

index.php

<div id="left_side">
       <h3>Toolbar</h3>
 </div>

  <div id="content">
      there will be refreshed index2.php
  </div>
  ......
   function doAjax() {

          var frm = $('#plotForm1');
          $.ajax({
              type: frm.attr('method'),
              url: frm.attr('action'),
              data: frm.serialize(),
              success: function (data) {

$('#content').html(data);

                            }
             });    
     }

index2.php

<form id="plotForm1" action="index2.php" onsubmit='doAjax(); return false;' method="post">
 ....
</form>

暂无
暂无

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

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