Senin, 06 November 2017

GET url atau lebih url di javascript

randval=Math.random();
            var url ='check_jenis_kpi.php?randval='+randval;
           
            sendReq(url, function processResponse(response1){
                cell2.innerHTML = '';

            });
          

            randval=Math.random();
            var url2 ='check_perspektif_kpi.php?randval='+randval;
           
            sendReq(url2, function processResponse(response2){
                cell3.innerHTML = '';

            });


function sendReq(url, callbackFunction) {
            var xmlhttp

            if (window.ActiveXObject){
                xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
            } else if (window.XMLHttpRequest) {
                xmlhttp = new XMLHttpRequest();
            }

            xmlhttp.onreadystatechange = function(){
               if (xmlhttp.readyState==4 && xmlhttp.status=='200'){
                    if (callbackFunction){
                        callbackFunction(xmlhttp.responseText)
                    }
               }
            }

            xmlhttp.open(\"GET\",url,true);
            xmlhttp.send();
        }

Tidak ada komentar: