echo "
- data akan tampil disini secara otomatis tanpa load halaman
?>
di bawah ini script di file tampil.js
================== start =====================
var nip="";
$(document).ready(function() {
nip = $("#nip").val();
selesai();
});
function selesai() {
setTimeout(function() {
update();
selesai();
}, 200);
}
function update() {
$.getJSON("tampil.php", {nip:nip} ,function(data) {
$("ul").empty();
$.each(data.result, function() {
$("ul").append("Pilih Kompetensi("+this['total']+")");
});
});
}
=================== end =====================
di bawah ini script di file tampil.php
=================== start ====================
include("$DOCUMENT_ROOT/koneksi.php");
$sql = "SELECT count(*) as total FROM table_siswa WHERE nip='$nip'";
$rs = $f->get_last_record($sql);
$total = $rs['total'];
$result = array();
array_push($result, array('total' => $total));
echo json_encode(array("result" => $result));
?>
=================== end====================