- Screen name: Daniel11111430242290
Daniel11111430242290's Profile
4 Posts
6 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- hello, i'm creating live search and show it to the tablehere the ajax$("#cari").on('keyup', function(){var cari = $("#cari").val();$.ajax({type: "post",url: "do_kasircari.php",data : {cari: cari},dataType: "text",success: function(data){$("#hasil").load(data);console.log(cari);console.log(data);}})});here is the console.logdata is right, but not showing. why? please help, thanks
- helloi was creating live username check for learninghere my codelogin.php$.ajax({url: "cek_username.php",type: "post",data: "username="+username,success: function(data){if(data == 0){$("#idErr").html("username tersedia");$("#id_daftar").css("outline-color","green");}else{$("#idErr").html("username tidak tersedia");$("#id_daftar").css("outline-color", "red");console.log(data);error_username = true;}},});cek_username.php (code for check username avaibility on database)<?phpinclude "koneksi.php";$username = $_POST['username'];$sql= "select * from login where username = '$username' ";$query= mysqli_query($conn, $sql);$data = mysqli_num_rows($query);echo $data;?>here is the form<div class="form-group"><label for="username">Username :</label><input type="text" style="max-width:90%;" class="form-control" name="id_daftar"id="id_daftar" placeholder="Masukkan Username Anda" autocomplete="off"maxlength="16" value="" /><div class="error" id="idErr"></div></div>console.logso i created in 2 php file, 1 is simple one for my learning purposebut after i implemented to another php for my project, it cannot get value from cek_username.php, and i dont know whyplease helpthanks
- hello,i'm newbie of jquery and ajax, so i created based on website that i readi already created simple live username check (and others) and i worksbut after i implement on to my project, it dosen't works, why?here the code:form code<form name="daftar" method="post" onsubmit="return validate_daftar()"><div class="form-group"><label for="username">Username :</label><input type="text" style="max-width:90%;" class="form-control" name="id_daftar" id="id_daftar" placeholder="Masukkan Username Anda" maxlength="16" autocomplete="off"/><div class="error" id="idErr"></div></div><div class="form-group"><label for="password">Password :</label><input type="password" style="max-width:90%;" class="form-control" name="pass" id="pass" placeholder="Masukkan Password Anda" maxlength="16" value="" /><input type="checkbox" onclick=password()> Tampil Password<div class="error" id="passErr"></div></div><div class="form-group"><label for="nama">Nama :</label><input type="text" style="max-width:90%" class="form-control" name="nama" id="nama" maxlength="50" placeholder="Masukkan Nama Sesuai KTP" value="" /><div class="error" id="namaErr"></div></div><div class="form-group"><label for="email">Email :</label><input type="email" style="max-width:90%;" class="form-control" name="email" id="email" placeholder="Masukkan Email Anda" value="" /><div class="error" id="emailErr"></div></div><div class="form-group"><label for="nomorhp">Nomor HP:</label><input type="number" style="max-width:90%;" class="form-control" placeholder="Masukkan Nomor HP Anda" name="nohp" id="nohp" maxlength="16" value="" /><div class="error" id="nohpErr"></div></div><button type="submit" name="daftar" value="daftar" class="btn btn-info">Daftar</button></div></form>jquery and ajax code:$(document).ready(function(){$('#id_daftar').keyup(function(){var id_daftar = $('#id_daftar').val();$.ajax({url: "regis_username.php",type: "post",data: "id_daftar="+id_daftar,dataType: "text",success: function(data){if(data == 1){$("#idErr").html("username tersedia");$("#idErr").css("outline-color", "green");}else{$("#idErr").html("username tidak tersedia");$("#idErr").css("outline-color", "red");console.log(id_daftar);console.log(data);}},});});searching code: (regis_username.php)<?phpinclude "koneksi.php";$username = $_POST['id_daftar'];$sql= "select * from login where username = '$username' ";$query= mysqli_query($conn, $sql);$count = mysqli_num_rows($query);echo $username."-".$count;?>console.logi don't know what wrong but, any help and explanation will be appreciated!
- 13-May-2020 10:20 PM
- Forum: Using jQuery
hello,
im just learning jquery and ajax via YT, and i tried to create a form with combo box, and show records from database based on combo box
after that, i want to store the data to the session
i already created the form that showing the records and already worked, but the button that i created that for store to the session, the ajax is not working.
ajax3.php (index)
<form action="cari.php" method="POST">
<select name="kamar">
<option value="regular single">Regular Single Rp 99.000</option>
<option value="regular double">Regular Double Rp 120.000</option>
<option value="family single">Family Single Rp 127.500</option>
<option value="family double">Family Double Rp 150.000</option>
<option value="vip single">V.I.P Single Rp 170.000</option>
<option value="vip double">V.I.P Double Rp 200.000</option>
</select>
<br>
<button type="submit" name="submit">Submit</button>
</form>
<br>
<div id="tampil"></div>
<script type="text/javascript">
$(document).ready(function(){
$('form').on('submit', function(e)
{
e.preventDefault();
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize(),
success: function(data){
$("#tampil").html(data);
},
});
$('.simpanData').on('submit', function(e)
{
e.preventDefault();
$.ajax({
type: "get",
url: $(this).attr('href'),
data: $(this).serialize(),
success: function(data){
$("#tampil").html(data);
},
});
});
});
});
here is cari.php (searching)
<?php
include "koneksi.php";
$jenis = $_POST['kamar'];
$sql= "select * from kamar where jkamar = '$jenis' ";
$result = mysqli_query($conn, $sql);
?>
<table>
<?php
if(mysqli_num_rows($result) > 0)
{
while ($data = mysqli_fetch_array($result))
{
$link_simpan = "<a class='simpanData' href='simpan2.php?nokmr=".$data['nokamar']."'>Simpan</a>";
?>
<tr>
<td value="<?php echo "nokamar = $data[nokamar]"; ?>"><?php echo $data['nokamar'];?></td>
<td><?php echo $link_simpan ?></td>
</tr>
<?php
}
}
else
{
echo "no more data!";
}
?>
</table>
any help will be appreciated, thanks
- «Prev
- Next »
Moderate user : Daniel11111430242290
© 2013 jQuery Foundation
Sponsored by and others.

