title: jquery ajax request within the joomla modal window
body: <p>I am useing modal window of native joomla codes. I am displaying a form wihchi is used to send mail from one user to another. The php,css and js codes are in tmpl file (by using JDocument) of view and js is like that;</p>
  
  <pre><code>var $j = jQuery.noConflict();
  $j(document).ready(function(){
      $j("#sendMail").click(function(){
          if(document.formvalidator.isValid(this.form)){
              $j("#mailSending").css("display","inline-block");
  
              $j.ajax({       
                  type: \'POST\',
                  url: \'index.php?option=mycomponent&amp;tmpl=component&amp;view=members\',
                  data: $j("form#mailForm").serialize(),
                  success: function(data,xhr,status){
                              $j("#mailSending").css("display","none");
                              $j("#mailMsg").css("display","inline-block");
                              setTimeout(function(){window.parent.SqueezeBox.close()},1000);
                              alert(status);
                           }
              });
          }else{
              $j("#mailMsg").text("'.JText::_('OFFER_EMPTY_FIELDS').'").css("display","inline-block").delay(1000).fadeOut("slow");
          }
      });                 
  });';
  </code></pre>
  
  <p>I am tracing the xhr with firebug when I triger the click function to loading icon is shown and task within the controller file is executed. Php file ends like that;</p>
  
  <pre><code>$send =&amp; $mailer-&gt;Send();
      if ( $send !== true ) {
          echo 'Error sending email: ' . $send-&gt;getMessage();
      } else {
          echo 'Mail sent';
      } 
      exit();
  </code></pre>
  
  <p>While the php function process ends the content within the modal window is changes with Mail Sent. But I want to hide the loading .gif and show a message. But the code don't do that. Any idea ?</p>