- Beranda
- Komunitas
- Tech
- Website, Webmaster, Webdeveloper
[HELP] Tolong Bantuin Tentang API gan , No 'Access-Control-Allow-Origin'


TS
link24
[HELP] Tolong Bantuin Tentang API gan , No 'Access-Control-Allow-Origin'
Saya Punya , Code ini gan , html javascript . mau baca hasil API dari PHP yang ada di server . nah tapi tidak bisa terbaca , keterngan nya
Ini Code nya :
Code:
Failed to load http://localhost/tes/bla.php: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Ini Code nya :
Code:
<!DOCTYPE html>
<html>
<body>
<h2>Get data as JSON from a PHP file on the server.</h2>
<p id="demo"></p>
<p id="demo2"></p>
[removed]
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myObj = JSON.parse(this.responseText);
document.getElementById("demo")[removed] = myObj.name;
document.getElementById("demo2")[removed] = myObj.age;
}
};
xmlhttp.open("GET", "http://localhost/tes/bla.php", true);
xmlhttp.send();
[removed]
</body>
</html>
0
678
2


Komentar yang asik ya
Urutan
Terbaru
Terlama


Komentar yang asik ya
Komunitas Pilihan