Just my problem is that I want to submit the form in a div with an empty action as a PHP script on the same page, a simple example to illustrate, since my page is too long
<html> <head> <script> $(document).ready(function() { $("#myDiv").delegate("form", "submit", function(event) { $.ajax({ data: $(this).serialize(), type: $(this).attr('method'), url: $(this).attr('action'), success: function(response) { $("#myDiv").slideUp(500, function() { $("#myDiv").html(response); $("#myDiv").slideDown(500); }); } }); return false; }); }); </script> <head> <form method="post" action=""> <p> enter your name</p> <input type="text" name="name" /> <input type="submit" name="save" /> </form> <?php if (isset($_POST['save'])) { echo $_POST['name']; } ?> </html>
The problem is that the action of the form is empty, and therefore, when I click the "Submit" button, nothing happens, so does anyone know how to solve the problem? PS: it is too difficult to extract the php script into the extrnak file, I am looking for an alternative solution.
source share