Form submit data to SQL DB without page reload (jQuery / PHP?) then change div content -


currently have form

<div id="subfooter"> <form name="subscribe" method="post"> <input type="email" placeholder="e-mail address"> <input type="submit" value="subscribe"> </form> </div> 

i have page called "_add_subscriber.php" has correct information take $_post data , push sql.

also have 2 forms on page. (each different identifiers).

now question is...

when submit button of form:subscribe hit want post data hidden _add_subscriber.php page enter data database. (not refreshing page!) on click want replace contents of 'subfooter' div like...

<span>thanks subcribing</span> 

thus hiding original form.

i hope makes sense, have @ other solution don't totally understand how collect data specific form. though seem trait php + jquery can complete above actions me!

setting html

<form name="subscribe" method="post" action="_add_subscriber.php"> 

simple ajax function use form submissions.

$('#subfooter form').on('submit', function() {      var $form = $(this);      $.ajax({         url: $form.attr('action'),         type: $form.attr('method'),         data: $form.serialize(),         success : function(data) {     // console.log(data);     // $('span').show(); // etc   }     });      return false; }); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -