Javascript: Difference between revisions

From Server STB
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 14: Line 14:
   });
   });
   }
   }
   async function ambil(){
   async function ambil(){
     var re = await get(url + "surah_list.json");
     var re = await get(url + "surah_list.json");

Latest revision as of 01:34, 28 June 2024

 <script>
 var url = "https://raw.githubusercontent.com/iherbs/quran-json/main/";
 async function get(file = "") {
 return new Promise((resolve, _reject) => {
   xmlhttp = new XMLHttpRequest();
   xmlhttp.open("GET", file);
   xmlhttp.onreadystatechange = function () {
     if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
       // console.log(xmlhttp.responseText);
       resolve(xmlhttp.responseText);
     }
   };
   xmlhttp.send();
 });
 }
 async function ambil(){
   var re = await get(url + "surah_list.json");
   document.write(re);
 }
 ambil();
 </script>