I don’t know if I have formulated the question exactly or not, if I correct it.

I have a modal window with a form that sends a post request to the script.php handler.

<form class="em" action="script.php"> <input type="email" name="email" id="email"><br> <button class="button7" name="sendbtn" >Оформить подписку</button> </form> 

Accordingly, after sending the form, the user throws on script.php. Is it possible to somehow execute this script without going to a file, can it be directly processed in this file? and after processing, change the contents of the diva, respectively. (yes, you can make a redirect in script.php, but this is not exactly what I need)

    2 answers 2

    Use the submit form event handler to send an ajax request. (Do not forget to add the jQuery library script to the page if it is not already there.)

     $('form.em').submit(function() { $.ajax({ type:'POST', url:'script.php', dataType:'html', data: $(this).serialize(), success:function(response){ $('#your div id').html(response); }, error:function(response){ alert('error, response - ' + response); } }); return false; }); 

      You may need to send an ajax request using js and modify the html js methods after the response.

      And it looks like you forgot to specify a method

       <form class="em" action="script.php" method="POST"> 
      • Yes, it was sealed off simply - sbaikov