Note that there are some explanatory texts on larger screens.

plurals
  1. POload xml file in background
    primarykey
    data
    text
    <p>I have a page that loads an XML file with thousands of Postal Codes into memory. Once the xml is loaded, a textbox and search button are displayed and the user can enter a postal code (zip code) and click search and some results will display. The problem is, the initial load takes a while and the page says "loading..." for 10-15 seconds before the textbox and search button appear. I need to make the search box/button appear faster/immediately, even if it means an extra bit of time on the searches. I admit, I'm more of a .net guy and don't know javascript/ajax real well. Here's the function that loads the xml. Can anyone help?</p> <pre><code>function importXML() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { var i,j; var xmlDoc=xmlhttp.responseXML; for (i=0; i&lt;arrServiceProviders.length;i++) { var regionList = xmlDoc.getElementsByTagName("region"); var postalCodeList = regionList[i].getElementsByTagName("postalcode"); for (j=0;j&lt;postalCodeList.length;j++) { arrServiceProviders[i][j]=postalCodeList[j].childNodes[0].nodeValue; } // debug time: //alert(arrServiceProviders[i]); } var searchForm = document.getElementById("search-wrapper"); var loadingPlaceholder = document.getElementById("loading"); loadingPlaceholder.className = "hidden"; searchForm.className = ""; } }; xmlhttp.open("GET","/agency-postal-codes.xml",true); xmlhttp.send(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload