Skip to content Skip to sidebar Skip to footer

Javascript Function Not Called

I´ve got a javascript method that calls a php method to get some data in the array 'availabletags'. To prove if the function is even called, I added availableTags[0] = 'Test'; W

Solution 1:

Learn and use AJAX to change your javascript array without to refresh your page: AJAX call looks like:

<script type='text/javascript'>
function yourFunction(str, typ)
    {
        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 && xmlhttp.status==200)
            {
                myArray = xmlhttp.responseText; //here is the result
            }
        }
        xmlhttp.open("GET","myFile.php?param1="+str ,true); //here you lunch myFile 
        xmlhttp.send();
    }
</script>

Post a Comment for "Javascript Function Not Called"