Before submitting my PHP page, I need to send an email. The mail script is in a file called sendmails.php. Is it possible to use JavaScript to send an AJAX request to send the email before submitting the page? Here is an example:
function submit_page()
{
//trying to run send_mail.php
..............................//ajax codes
............................
xmlhttp.open("GET","send_mail.php",true);
xmlhttp.send();
.................................
if(a)
form.action = 'one.php'
else
form.action = 'two.php'
form.submit()//form submitting using javascript
}
Will this method execute the send_mail.php file on the server?
Appreciate your help.