I need to send an email from a server side script without loading a new page (which a form action would do). I have tried with XMLHttpRequest
and some code I found somewhere:
UniAjax.request({
uri: 'sendMail.php',
method: 'post',
arguments: {
bodysHTML: document.body.innerHTML
}
});
But neither of them worked. Does anyone have any ideas?
I do not know the action of form you are using is in same page or other page.php.
In both the case after sending mail ie after mail function if the mail has been sent properly you can specify header to redirect the page.
$sentmail=mail($to, $subject, $message, $header);
if($sentmail)
{
header('Location: http://www.example.com/');
}
If u don't want the page to load only when u submit form, have a look at - http://jquery.malsup.com/form/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.