ovar . tk/server.php:
[{"nama":"cilok","tempat":"Jajanan cilok dapat di temukan di daerah sekitar gerbang FAPET","gambar":"cilok.jpg"},{"nama":"martabak","tempat":"Jajanan martabak dapat di temukan di daerah pasar Dinoyo lama","gambar":"martabak.jpg"},{"nama":"cwie mi","tempat":"Jajanan cwie mi dapat di temukan di daerah jalan sumbersari gang 3 ","gambar":"martabak.jpg"},{"nama":"mcd","tempat":"Restoran Mc Donalds dapat di temukan di daerah pasar Dinoyo lama","gambar":"martabak.jpg"},{"nama":"mcd","tempat":"Tidak Ditemukan","gambar":""}]
and my code is test.html:
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://ovar.tk/server.php",function(result){
$.each(result, function(i, field){
$("div").append(field.nama + " ");
});
});
});
});
</script>
</head>
<body>
<button>Get JSON data</button>
<div></div>
</body>
</html>
nothing happen when i click the button, it show the data when the url is localhost im newbie in getting json data, so please help me! Thank you all! :D