title: How to use OnComplete?
body: <p>I'm trying to use a Javascript/AJAX function that send an email (using a PHP page).</p>
  
  <p>The function is:</p>
  
  <pre><code>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();
  });
  </code></pre>
  
  <p>It works fine, but i cannot manage the response from PHP page, where i've this code:</p>
  
  <pre><code>&lt;?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-&gt;get('mail_subject');
      $reciptient =   explode(',', $params-&gt;get('receipt_email'));
      $app =      JFactory::getApplication();
      $sender =   array($app-&gt;getCfg('mailfrom'), $app-&gt;getCfg('fromname'));
  
              // make email
      $Body = '&lt;strong&gt;Azienda:&lt;/strong&gt; '.$name."&lt;br /&gt;";
      $Body .= '&lt;strong&gt;Riferimento:&lt;/strong&gt; '.$rif."&lt;br /&gt;";
      $Body .= '&lt;strong&gt;Numero di telefono:&lt;/strong&gt; '.$phone."&lt;br /&gt;";
      $Body .= '&lt;strong&gt;Pagina da cui &amp;egrave; stato richiesto il contatto:&lt;/strong&gt; &lt;a href='.$uri.'&gt;'.$uri."&lt;/a&gt;";
  
      $mailer =&amp; JFactory::getMailer();
      $mailer-&gt;setSender($sender);
      $mailer-&gt;addRecipient($reciptient);
      $mailer-&gt;setSubject($subject);
      $mailer-&gt;isHTML(true);
      $mailer-&gt;Encoding = 'base64';
      $mailer-&gt;setBody($Body);
      if ($name == '' || $rif == '' || $phone == '' || $name == 'Azienda' || $rif == 'Riferimento' || $phone == 'Telefono') {
      } else {
      $send =&amp; $mailer-&gt;Send();
      }
  
      if ($send != true) {
        return 'no';
      } else {
        return 'ok';
      }
  }
  
      }
      ?&gt;
  </code></pre>
  
  <p>When alert(response) is displayed i can see the whole html code ( included) from the page, but I'm not able to show only the "return" from the PHP page.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>You can check an example of my problem here: <a href="http://www.sevenit.it" rel="nofollow">http://www.sevenit.it</a> (check at the top right of the page after 3 seconds)</p>
  
  <p>Thanks</p>