Posting a form to a php file that will process it and show echoes to facebox

135 Views Asked by At

Need some help here. I have a form that will be fetched to another php file that is on its "action" attribute and must display the echoes in that php file. But, when I submit it. It only shows a blank facebox pop up. I think theres a little problem within the jquery. Anyone who can fix this? Thanks :)

heres my form:

<form action="Examinersubmit.php" name="asign" id="asign" method="POST">
<input id ="adfirstname"  name="adfirstname"  type="text" onkeyup="isalpha(this)" class="input_field"  maxlength="60" />
<input id="adlastname" name="adlastname" type="text" onkeyup="isalpha(this)" class="input_field"  maxlength="60" />
<input type="submit" id="AdReg" name="AdReg" class="submit_btn float_l" value="Register" />
<input type="hidden" value="0" name="level" />
<input  type="text" class="input_field" id="sec1" name="sec1" />
<input type="reset" name="Submit4" class="submit_btn float_l" value="Clear All" />
<input  type="text" class="input_field" id="sec2" name="sec2" />
<input  type="text" class="input_field" id="sec3" name="sec3" />
</form>

heres the jquery script:

  <script type="text/javascript">
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox({

        loadingImage : 'src/loading.gif',
        closeImage   : 'src/closelabel.png'

      });
       $("#asign").submit(function() {
    var href = $(this).attr('action');
    $("<a>").attr('href',href).facebox().click();
    return false;
    });
    });
  </script>

The codes on the examinersubmit.php is working fine when it is "not" on facebox.

1

There are 1 best solutions below

3
On

you are returning false in the submit callback, your php script is never submitted to. Just providing the action url to facebox will not submit the form and show the results in it. If you are wanting to get the output of the script you need to use ajax

$("#asign").submit(function(e) {
   e.preventDefault();
   var href = $(this).attr('action');
   $.ajax({
      url:href,
      type:"POST",
      data:$(this).serialize(),
      dataType:"html",
      success:function(data){
         //data holds the html returned by the php script
         //do whatever you need to put the html into facebox.
      }
   });
});