POST form with jQuery (Ajax)


/ Published in: JavaScript
Save to your folder(s)

This send any value via POST to a PHP page. It is done with AJAX, so the POST return can be used on the same page as the submit


Copy this code and paste it in your HTML
  1. // On click "button.submit"
  2. $("button#submit").click(function () {
  3. // Send to submit.php
  4. $.post("controller/submit.php", {
  5. // Send these values via POST
  6. val1: $("#val1").val(),
  7. val2: $("#val2").val()
  8. }, function(result){
  9. // Return result
  10. $('#output').html(result);
  11. });
  12. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.