tengo el siguiente codigo:
Código Javascript :
window.onload= function(){
tabla = document.getElementById("pregunta");
jencu= ajax("GET","datos/encuesta.json",true,"lee")
}
function ajax(metodo,url,bolean,que){
var xhr;
if(window.XMLHttpRequest){//objeto en moz y chrome
xhr = new XMLHttpRequest();
}else{// objeto en ie
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange=function(){
if (xhr.readyState==4 && xhr.status==200){
if(que == "lee"){
encuesta=xhr.responseText;
encuesta = JSON.parse(encuesta)// quiero retornar este objeto json a la variable jencu
alert(xhr.getAllResponseHeaders());
}
}
}
xhr.open(metodo,url,true);
///xhr.overrideMimeType("application/json");;
xhr.send();
} 