Saturday, 23 February 2019

js : parse json COMPLETED

<!DOCTYPE html>
<html>
<body>
<script>

var gethttp = new XMLHttpRequest();
gethttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    var load = JSON.parse(this.responseText);
    //select from json
    var x = load.nama;
    var y = load.task;
    // var y = load.pets[1].name;
    //render and to html
    document.querySelector("#nama").innerHTML = x;
    document.querySelector("#alamat").innerHTML = y;
  }
};
// gethttp.open("GET", "./numerologi/json.txt", true);
gethttp.open("GET", "seed/sprout", true);
gethttp.send();
</script>


<b id="nama"></b></br>
<b id="alamat"></b>
</body>
</html>

//htaccess for apache

RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+)\.txt [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.txt -f
RewriteRule ^ %{REQUEST_URI}.txt [NC,L]

email mailto: pretext

 <a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...