0

我正在尝试使用发送电子邮件的 Javascript/AJAX 函数(使用 PHP 页面)。

功能是:

new Request({
    method: "post",
    data: this,
    onRequest: function() {
      $('amCallMeBackForm').empty().addClass('amCallMeBackWait');
      $('callback').setStyle('background', 'url(\'http://www.mysite.it/modules/mod_amcallmeback/assets/sfondo_callback.png\') no-repeat transparent');
      $('callback').setStyle('height', '73px');
    },
    onComplete: function(response) {
        $('amCallMeBackForm').removeClass('amCallMeBackWait');
        $('amCallMeBackForm').addClass('amCallMeBackSent');
        alert(response);
    }
}).send();
});

它工作正常,但我无法管理来自 PHP 页面的响应,我有以下代码:

<?php 
class modAmCallMeBackHelper
{

function send($params) {
    // Check for request forgeries
    JRequest::checkToken() or die( 'Invalid Token' );
            // get data
    $name =     JRequest::getVar('name', '');
    $rif =      JRequest::getVar('rif', '');
    $phone =    JRequest::getVar('phone', '');
    $uri =      JRequest::getVar('uri', '');

            // get module params
    $subject =  $params->get('mail_subject');
    $reciptient =   explode(',', $params->get('receipt_email'));
    $app =      JFactory::getApplication();
    $sender =   array($app->getCfg('mailfrom'), $app->getCfg('fromname'));

            // make email
    $Body = '<strong>Azienda:</strong> '.$name."<br />";
    $Body .= '<strong>Riferimento:</strong> '.$rif."<br />";
    $Body .= '<strong>Numero di telefono:</strong> '.$phone."<br />";
    $Body .= '<strong>Pagina da cui &egrave; stato richiesto il contatto:</strong> <a href='.$uri.'>'.$uri."</a>";

    $mailer =& JFactory::getMailer();
    $mailer->setSender($sender);
    $mailer->addRecipient($reciptient);
    $mailer->setSubject($subject);
    $mailer->isHTML(true);
    $mailer->Encoding = 'base64';
    $mailer->setBody($Body);
    if ($name == '' || $rif == '' || $phone == '' || $name == 'Azienda' || $rif == 'Riferimento' || $phone == 'Telefono') {
    } else {
    $send =& $mailer->Send();
    }

    if ($send != true) {
      return 'no';
    } else {
      return 'ok';
    }
}

    }
    ?>

显示警报(响应)时,我可以从页面中看到整个 html 代码(包括),但我无法仅显示 PHP 页面的“返回”。

我究竟做错了什么?

您可以在这里查看我的问题示例:http ://www.sevenit.it (3 秒后在页面右上角查看)

谢谢

4

1 回答 1

1
alert(response.responseText);  

我相信这是要走的路。

编辑:或者你可能想要做的是:

$('#amCallMeBackForm').html(response.responseText)

不是 100% 确定你在问什么。

于 2013-05-08T09:06:49.017 回答