Submit form without page reloading Submit form without page reloading php php

Submit form without page reloading


I've found what I think is an easier way. If you put an Iframe in the page, you can redirect the exit of the action there and make it show up.You can do nothing, of course. In that case, you can set the iframe display to none.

<iframe name="votar" style="display:none;"></iframe><form action="tip.php" method="post" target="votar">    <input type="submit" value="Skicka Tips">    <input type="hidden" name="ad_id" value="2">            </form>


You'll need to submit an ajax request to send the email without reloading the page. Take a look at http://api.jquery.com/jQuery.ajax/

Your code should be something along the lines of:

$('#submit').click(function() {    $.ajax({        url: 'send_email.php',        type: 'POST',        data: {            email: 'email@example.com',            message: 'hello world!'        },        success: function(msg) {            alert('Email Sent');        }                   });});

The form will submit in the background to the send_email.php page which will need to handle the request and send the email.


You either use AJAX or you

  • create and append an iframe to the document
  • set the iframes name to 'foo'
  • set the forms target to 'foo'
  • submit
  • have the forms action render javascript with 'parent.notify(...)' to give feedback
  • optionally you can remove the iframe