0

我需要从服务器端脚本发送电子邮件而不加载新页面(表单操作会这样做)。我已经尝试过XMLHttpRequest并在某处找到了一些代码:

UniAjax.request({
    uri: 'sendMail.php',
    method: 'post',
    arguments: {
        bodysHTML: document.body.innerHTML
    }
});

但他们都没有工作。有没有人有任何想法?

4

1 回答 1

0

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 i.e 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/

于 2012-05-03T11:28:25.057 回答