Jump to content
Fórum Script Brasil
  • 0

Quando carregar uma página aparece gif loading


miro
 Share

Question

Estou usando uma função onclick="loadXMLDoc" que chama outra pagina que carrega na mesma.

Como faço para colocar dentro da função: function loadXMLDoc(url)

Aparecer aquela imagem em loading.gif, depois de carregar aparecer a página.

Função essa:

<script type="text/javascript">
var xmlhttp;
function loadXMLDoc(url)
{
var postcode = document.getElementById('postcode').value;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  xmlhttp.onreadystatechange=stateChange;
  xmlhttp.open("GET",url+"&postcode="+postcode,true);
  xmlhttp.send(null);
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttp.onreadystatechange=stateChange;
  xmlhttp.open("GET",url+"&postcode="+postcode,true);
  xmlhttp.send();
  }
}

function enviaReq(url, tipo)
{
var postcode = document.getElementById('postcode').value;
var shipping = document.getElementById('shipping_'+tipo).value;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  xmlhttp.onreadystatechange=stateChange;
  xmlhttp.open("GET",url+"&postcode="+postcode+"&shipping="+shipping,true);
  xmlhttp.send(null);
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttp.onreadystatechange=stateChange;
  xmlhttp.open("GET",url+"&postcode="+postcode+"&shipping="+shipping,true);
  xmlhttp.send();
  }
}

function stateChange()
{
if (xmlhttp.readyState==4)
  {
  if (xmlhttp.status==200)
    {
    // process whatever has been sent back here
    document.getElementById('test').innerHTML=xmlhttp.responseText;
    }
  else
    {
    alert("...");
    }
  }
}
</script>
Botão esse:
<?php echo SHOPPING_CART_POST_CODE. ': <input type="text" name="postcode" id="postcode" />' . '   <button type="button" onclick="loadXMLDoc(\'' . tep_href_link("shipping_quote.php") . '\')">' . ESTIMATE_BUTTON . '</button>'  ?>

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.9k
    • Total Posts
      648.7k
×
×
  • Create New...