I want to catch cross domain response in pure javascript ajax not using jquery or other external libraries.
var xmlhttp, response;
try {
    xmlhttp = new XMLHttpRequest(); 
} catch(e) { 
   try { 
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e2) { 
       try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
    }
}
xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState==4) { 
        if(callback != undefined) { 
              console.log(xmlhttp.responseText);
        }
    }
}
url = "http://xxxx.com/layer.php?callback=callRes";
xmlhttp.open("GET", url, false);
xmlhttp.setRequestHeader("Content-Type",
                    "application/json,application/javascript,text/javascript");
xmlhttp.send();
spent lots of time and googling but not find any solution
suggestions are most welcome but not script method only pure javascript ajax
 
     
     
    