0

In my web portal, I have one page index.php which have <div> tag which content is obtained using AJAX. At this <div> tag the page index2.php is called. At the page index2.php there is one form which should be submitted using AJAX (without refreshing whole page, just refreshing index2.php). After submit, index2.php should be again called but with some additional arguments from form (over POST).

Problem is because POST request is sent, but it looks like content of <div> (index2.php) is not changed. Here is the code:

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>
4
  • why action is hcm_result.php ? did the ajax call change data in db? After changing , where is the code to reload data ? Commented Jan 7, 2015 at 17:20
  • It is mistake in typing code here, it should be index2.php. Dont ajax function automatically reload this page? Commented Jan 7, 2015 at 17:27
  • ajax can update db and reload data if you wrote that :-) automatically i dont know Commented Jan 7, 2015 at 17:29
  • How to reload page index2.php? :) I was not able to find function to do that Commented Jan 7, 2015 at 17:30

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.