简体   繁体   中英

PHP FORM reload into load div

I use a Jquery function to Load Php Content into a div on the Indexpage(Kinda like a masterpage) But I have to make an email form( I use a submit button) but now i want it to reload in the div and not the whole page?

This is my Menu Script(Kinda tried all sort of things) This is all located on the INDEX PAGE.PHP

      $('.menut').click(function () {
       var phpFile = $(this).attr('id') + '.php';
       $('#box1').load(phpFile, function () {


               $('#contactForm').click(function (e) {
                   e.preventDefault();
                   var data = $(this).serialize();
                   $('#box1').load($(this).attr('action'), data);


   });
});

This is located on the Form.php page

  <form id="contactform" method="POST" action="insch.php"> 

I think you should use

$('#contactform').submit(function (e){
   e.preventDefault();
   $('#box1').load(....)// 
   return false;
});

This will say when form is submitted, stop the browser from doing it's default action, then return false, to stop any other actions if any.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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