title: reload only a module in joomla?
body: <p>I have a module that lets users rate an image.  The problem is that when the user hits the submit button to rate, it reloads the entire page instead of just the module.  Is it possible to make it so that it reloads just the module, or at least if it has to reload the entire page to make it automatically take the user back to the bottom of the page where the module is?</p>
  
  <pre><code>&lt;?php // no direct access
  defined('_JEXEC') or die('Restricted access'); ?&gt;
  &lt;script type="text/javascript"&gt;
  
      function getCheckedRadio(radio_group) 
  {
      for (var i = 0; i &lt; radio_group.length; i++) 
      {
          var button = radio_group[i];
          if (button.checked) 
          {
              return button;
          }
      }
      return undefined;
  }
  
  
      function trim(s){   
              var i;
              var returnString = "";
              for (i = 0; i &lt; s.length; i++){   
                  // Check that current character isn't whitespace.
                  var c = s.charAt(i);
                  if (c != " ") returnString += c;
              }
           return returnString;
      }
      //check is integer
      function isInteger(s){   
          var i;
          if(trim(s)==''){return false;}
          for (i = 0; i &lt; s.length; i++){   
              var c = s.charAt(i);
              if (((c &lt; "0") || (c &gt; "9"))) return false;
          }
          return true;
      }
      function xmlhttpPost(strURL) {
                              var xmlHttpReqs = false;
                              if (window.XMLHttpRequest) {
                                  xmlHttpReqs = new XMLHttpRequest();
                              }else if (window.ActiveXObject) {
                                  xmlHttpReqs = new ActiveXObject("Microsoft.XMLHTTP");
                              }
                              xmlHttpReqs.open('POST', strURL, true);
                              xmlHttpReqs.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                              xmlHttpReqs.onreadystatechange = function() {
                                  if (xmlHttpReqs.readyState == 4) {
  
                                      updatepage(xmlHttpReqs.responseText);
                                      setTimeout("window.location = 'index.php'",2000);
                                  }
                              }
                              document.getElementById("load").innerHTML ="Loadding...";
                              xmlHttpReqs.send(getquerystring());
                          }
      function getquerystring() {
                              var form     = document.forms['rateForm'];
                              var numbervote = form.numbervote.value ;
                              var name = form.name.value ;
                              var folder = form.folder.value ;
                              qstr = 'w='+escape(numbervote)+'&amp;w1='+escape(name)+'&amp;w2='+escape(folder);
                              return qstr;
                          }
      function chck(){
                              xmlhttpPost("&lt;?php echo JURI::root(); ?&gt;modules/mod_image_ratting/saverate.php");
                          }
                          function updatepage(str){
                              document.getElementById("load").innerHTML =  str;
                              document.getElementById("load").style.visibility = "visible";
                          }
      function submitVote()
  {
  
  var form = document.rateForm;
  var checkedButton = getCheckedRadio(document.rateForm.elements.numbervote);
  if (checkedButton) 
  {
      selectedvalue = checkedButton.value;
  }
  
          if(selectedvalue=='')
      {
      document.getElementById('numbervoteErr').style.display='block';
      return false;
  }else if(!isInteger(selectedvalue)){
      document.getElementById('numbervoteErr').style.display='block';
      return false;
  }else if(selectedvalue &gt; 10){
      document.getElementById('numbervoteErr').style.display='block';
      return false;
  }
  else
      {
      chck();
  }
  
      }
  
  &lt;/script&gt;
  
  &lt;form action="&lt;?php echo JRoute::_( 'index.php' );?&gt;" method="get" name="rateForm" id="rateForm" class="form-validate" &gt;
      &lt;table style="width:100%;border:0px;"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;?php if ($link) : ?&gt;
                  &lt;a href="&lt;?php echo $link; ?&gt;" target="_self"&gt;
                  &lt;?php endif; ?&gt;
                      &lt;?php echo JHTML::_('image', $image-&gt;folder.'/resize/'.$image-&gt;name, $image-&gt;name); ?&gt;
                  &lt;?php if ($link) : ?&gt;
                  &lt;/a&gt;
                  &lt;?php endif; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php
              //if($image-&gt;rates &gt; 0){
                  ?&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;?php JHTML::_( 'behavior.modal' ); ?&gt;
                          &lt;?php echo $image-&gt;rates;?&gt; people liked this photo &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a class="modal" href="index2.php?option=com_imageratting&amp;task=viewrates&amp;file=&lt;?php echo  $image-&gt;name;?&gt;&amp;f=&lt;?php echo htmlentities(urlencode($image-&gt;folder));?&gt;" style="text-decoration:underline;"&gt;View Full Size Image&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;?php
              //}
          ?&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;span&gt;
                      &lt;input type="radio" name="numbervote" value="1" checked /&gt; 1&lt;br /&gt;
                      &lt;input type="radio" name="numbervote" value="2" /&gt; 2&lt;br /&gt;
                      &lt;input type="radio" name="numbervote" value="3" /&gt; 3&lt;br /&gt;
                      &lt;input type="radio" name="numbervote" value="4" /&gt; 4&lt;br /&gt;
                      &lt;input type="radio" name="numbervote" value="5" /&gt; 5&lt;br /&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
                      &lt;input type="button" value="Rate the image!" onclick="submitVote();"/&gt;
                  &lt;/span&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;div id="load" style="color:red;font-size:11px;font-style:italic;"&gt;&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;span style="display:none;color:red;font-size:11px;font-style:italic;" id="numbervoteErr"&gt;&lt;?php echo 'Rating must be a number between 0 and 5';?&gt;&lt;/span&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
      &lt;input type="hidden" name="isSaveRate" value="1" /&gt;
      &lt;input type="hidden" name="option" value="com_imageratting" /&gt;
      &lt;input type="hidden" name="name" value="&lt;?php echo $image-&gt;name; ?&gt;" /&gt;
      &lt;input type="hidden" name="folder" value="&lt;?php echo $image-&gt;folder; ?&gt;" /&gt;
      &lt;input type="hidden" name="task" value="rate" /&gt;
  &lt;/form&gt;
  </code></pre>