jquery doesn't get loaded, if i don't reload page
<p>This code works only if I reload/refresh page, otherwise it doesn't work, I susspect issue is, because I use Jquery + normal javascript.</p>

<p>I have form and there is input which uses autocomplete, but while you go trough form next, it doesn't work. </p>

<p>The point is that input with #SchoolName isn't on first page is on 2nd page (after showcart(); function is trigered)...</p>

<p>Anyone have any ideas why my jquery code doesn't load properly?</p>

<p>I have this code:</p>

<pre><code>&lt;script type="text/javascript" language="javascript"&gt;
    function autocomplete() {
        $("#SchoolName").autocomplete("ajaxFuncs.php", {
            cacheLength:1,
            mustMatch:1,
            extraParams: {getSchoolName:1}
        });
    };

    $(document).ready(function(){
        setTimeout("autocomplete()", 500);
    });

    function showVal(str) {
        if (str == "") {   
            document.getElementById("txtHint").innerHTML = "* Please type in School Name.";
            return;
        }
        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) {
                if (xmlhttp.status == 200) { // break this into 2 statements so you can handle HTTP errors
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                } else {
                document.getElementById("txtHint").innerHTML = "AJAX Error (HTTP "+xmlhttp.status+")";
                }
            }
        }; // functions declared in this way should be followed by a semi colon, since the function declaration is actually a statement.

        // encodeURIComponent() does all the escaping work for you - it is roughly analogous to PHP's urlencode()
        // xmlhttp.open("GET","ajaxFuncs2.php?q="+encodeURIComponent(str),true);

        xmlhttp.open("GET","ajaxFuncs2.php?q="+encodeURIComponent(str),true);
        xmlhttp.send();
    }
&lt;/script&gt;



&lt;script&gt;
    function ajax(doc)
    {
        doc = null;
        if (window.XMLHttpRequest) {
            try {
                doc = new XMLHttpRequest();
            }
            catch(e) {
                if(SBDebug) 
                    alert("Ajax interface creation failure 1");
            }
        }
        else if (window.ActiveXObject) {
            try {
                doc = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e) {
                try {
                    doc = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e) {
                    if(SBDebug)
                        alert("Ajax interface creation failure 2");
                }
            }
        }
        return doc;
    }



    function postIt(params) {
        var doc;
        // alert("postIt: " + params);  

        if(params == "")
            params = "nada=0";

        doc = ajax(doc);

        if (doc) {
            var url = window.location.href;
            url = url.substr(0, url.lastIndexOf("/") + 1) + "clientCartPost.php";

            // alert(url);
            doc.open("POST", url, false);

            //Send the proper header information along with the request
            doc.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            doc.setRequestHeader("Content-length", params.length);
            doc.setRequestHeader("Connection", "close");

            document.body.style.cursor = "wait";
            doc.send(params);
            document.body.style.cursor = "default";

            if(doc.responseText == "timeout") {
                alert("Timed out");
                document.location = "index.php";
            }
            return doc.responseText;
        }
        return "Connection Failed";
    }





    function saveCC() {
        var doc;
        doc = ajax(doc);

        if(params == "")
        params = "nada=0";

        if (doc) {
            var params = "";
            var eVisi = document.getElementById("visiCard");
            var eCard = document.getElementById("x_card_num");

            if(eVisi.value.indexOf("*") &lt; 0)
                eCard.value = eVisi.value;

            for(i=0; i&lt;document.CC.elements.length; i++) {
                if(document.CC.elements[i].name == "visiCard")
                    continue;

                params += getElemValue(document.CC.elements[i]) + "&amp;";
            }

            doc.open("POST", "https://dot.precisehire.com/clientCartStoreCard.php", false);

            //Send the proper header information along with the request
            doc.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            doc.setRequestHeader("Content-length", params.length);
            doc.setRequestHeader("Connection", "close");

            document.body.style.cursor = "wait";
            doc.send(params);
            document.body.style.cursor = "default";

            // alert(doc.responseText);
            return true;
        }
        return false;
    }



    function getElemValue(item)

    {

    // alert("Getting: " + itemBase + itemID);

    // alert(itemBase + "" + itemID);

        if(item.type == "radio" || item.type == "checkbox")

        {

            if(!item.checked)

                return "";

        }

        if(item.type == "select-one")

        {

            value = item.options[item.selectedIndex].value;

        }

        else

            value = item.value;

        return item.name + "=" + escape(value) + "&amp;";

    }



    function    makePie()

    {

        var contents = postIt("command=getProgress");



        document.getElementById("step2").className = "bx2";

        document.getElementById("step3").className = "bx2";

        document.getElementById("step4").className = "bx2";

        if(contents &gt; 0)

            document.getElementById("step2").className = "bx1";

        if(contents &gt; 1)

            document.getElementById("step3").className = "bx1";

        if(contents &gt; 2)

            document.getElementById("step4").className = "bx1";

    }



    var gbColor;



    function    RedIn(start)

    {

        var id;



        if(start)

            gbColor = 0;

        gbColor += 32;

        if(gbColor &gt; 255)

            gbColor = 255;

        id = 0;

        var obj = document.getElementById("red" + id);

        while(obj != undefined)

        {

            obj.style.backgroundColor = 'rgb(255,' + gbColor + ',' + gbColor + ')'; 

            id++;

            obj = document.getElementById("red" + id);

        }

        if(gbColor &lt; 255 &amp;&amp; id &gt; 0)

            setTimeout("RedIn(0)", 100);

    }



    function    showCart(next)

    {

        var ca = document.getElementById("cartArea");

        var params = "";



        for(i=0; i&lt;document.clientCart.elements.length; i++)

        {

            param = getElemValue(document.clientCart.elements[i]);

            if(param != "")

                params += param + "&amp;";

        }

        if(next)

            params += "Next=1";

    // alert(params);

        ca.innerHTML = postIt(params);



        makePie();

    //  RedIn(1);

    }



    function    tabIfComplete(formField, maxSize, nextField, e)

    {

        if(window.event) // IE

        {

            keynum = e.keyCode;

        }

        else if(e.which) // Netscape/Firefox/Opera

        {

            keynum = e.which;

        }

        if(keynum &lt; 48)

            return;

        if(formField.value.length &gt;= maxSize)

        {

            var nf = document.getElementById(nextField);



            if(nf)

                nf.focus();

        }

    }



    function    sendCommand(command)

    {

        var ca = document.getElementById("cartArea");

        var params = "command=" + command;

        var submitOrder = command.indexOf('submitOrder') &gt;= 0;

    // alert(command);

        if(submitOrder)

        {

            if(document.getElementById("RESULT").checked)

            {

                params += "&amp;postSettlement=result";

    /*

                n = postIt(params);

                alert(nOID);

                if(nOID &gt; 0)

                    document.location="orderreview.php?id=" + nOID;

                return;

    */

            }

            else if(document.getElementById("REPORT").checked)

            {

                params += "&amp;postSettlement=report";

            }

            else if(document.getElementById("DUPEORDER").checked)

            {

                params += "&amp;postSettlement=dupeorder";

            }

            postIt(params);

            document.location="cart.php";

            return;

        }

        else if(command.indexOf('priorSearches') &gt;= 0)

        {

            document.location="orderreview.php?ssnlist=1";

        }

        else if(command.indexOf('addState') &gt;= 0)

        {

            for(i=0; i&lt;document.clientCart.elements.length; i++)

            {

                if(document.clientCart.elements[i].name != "Next")

                    params += "&amp;" + getElemValue(document.clientCart.elements[i]);

            }

        }

        ca.innerHTML = postIt(params);

        makePie();

    }



    function    doReset()

    {

        var ca = document.getElementById("cartArea");



        ca.innerHTML = "";

        ca.innerHTML = postIt("reset=1");

        makePie();

    }



    function    dupeOrder()

    {

        var ca = document.getElementById("cartArea");



        ca.innerHTML = "";

        ca.innerHTML = postIt("dupeOrder=1");

        makePie();

    }



    function    resetCart()

    {

        if(confirm("Empty current cart and start over? Are you Sure?"))

            doReset();

    }



    function    saveCart()

    {

        var ca = document.getElementById("cartArea");

        var params = "";



        for(i=0; i&lt;document.clientCart.elements.length; i++)

        {

            params += getElemValue(document.clientCart.elements[i]) + "&amp;";

        }

        params += "saveExit=1";

        ca.innerHTML = postIt(params);

        makePie();

        RedIn(1);

    }



    function    deleteOrderItem(command)

    {

        if(!confirm("Delete this search? Are you Sure?"))

            return;



        var ca = document.getElementById("cartArea");

        var params = "command=" + command;



        ca.innerHTML = postIt(params);

        makePie();

    }



    // alert("Reloaded");



    setTimeout("showCart();", 100);

&lt;/script&gt;
</code></pre>
