51 lines
2.2 KiB
JavaScript
51 lines
2.2 KiB
JavaScript
function search(){
|
|
$("#loading").show(); // Tampilkan loadingnya
|
|
|
|
$.ajax({
|
|
type: "POST", // Method pengiriman data bisa dengan GET atau POST
|
|
url: baseurl + "form/search", // Isi dengan url/path file php yang dituju
|
|
data: {no_pendaftaran : $("#no_pendaftaran").val()}, // data yang akan dikirim ke file proses
|
|
dataType: "json",
|
|
beforeSend: function(e) {
|
|
if(e && e.overrideMimeType) {
|
|
e.overrideMimeType("application/json;charset=UTF-8");
|
|
}
|
|
},
|
|
success: function(response){ // Ketika proses pengiriman berhasil
|
|
$("#loading").hide(); // Sembunyikan loadingnya
|
|
|
|
if(response.status == "success"){ // Jika isi dari array status adalah success
|
|
$("#nama_lengkap").val(response.nama_lengkap); // set textbox
|
|
$("#sekolah_asal").val(response.sekolah_asal); // set textbox
|
|
$("#kd_kompetensi").val(response.kd_kompetensi); // set textbox
|
|
$("#kompetensi").val(response.kompetensi); // set textbox
|
|
$("#gelombang").val(response.gelombang); // set textbox
|
|
$("#no_hp").val(response.no_hp); // set textbox
|
|
$("#nama_ayah").val(response.nama_ayah); // set textbox
|
|
$("#tlp_ayah").val(response.tlp_ayah); // set textbox
|
|
$("#nama_ibu").val(response.nama_ibu); // set textbox
|
|
$("#tlp_ibu").val(response.tlp_ibu); // set textbox
|
|
}else{ // Jika isi dari array status adalah failed
|
|
alert("No. Pendaftaran Tidak Ditemukan / Sudah Mengikuti Tes..!");
|
|
}
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) { // Ketika ada error
|
|
alert(xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
$("#loading").hide(); // Sembunyikan loadingnya
|
|
|
|
$("#btn-search").click(function(){ // Ketika user mengklik tombol Cari
|
|
search(); // Panggil function search
|
|
});
|
|
|
|
$("#no_pendaftaran").keyup(function(){ // Ketika user menekan tombol di keyboard
|
|
if(event.keyCode == 13){ // Jika user menekan tombol ENTER
|
|
search(); // Panggil function search
|
|
}
|
|
});
|
|
});
|