質問

JSON文字列にAJAX要求を作成してから、イベントOnReadyStateChangeから "jacu"変数に "jacu"変数から "jacu"変数に "jacu"変数から "jacu"変数に "jacu"変数に返します。

彼女のコード:

window.onload= function(){
 enter code here`tabla = document.getElementById("pregunta");
 enter code here`jencu= ajax("GET","datos/encuesta.json",true,"lee")
 }

function ajax(metodo,url,bolean,que){
   var xhr;
   if(window.XMLHttpRequest){
      xhr = new XMLHttpRequest();
   }else{ 
       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)
               }
           }
    }

   xhr.open(metodo,url,true);
   xhr.send();
}
.

役に立ちましたか?

解決

Encuestaがグローバルにアクセスできるようにしたい場合は、機能外に宣言する必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top