tidak bisa update modal dengan jquery

Selamat malam.saya ingin mengupdate data dengan modal melalui jquery.

ini kira-kira kode saya:

<?php
include("koneksi.php");

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Kode Rekening</title>
    <link rel="stylesheet" href="assets/bootstrap-5.0.2-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/jquery/jquery360.js">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="assets/fontawesome620/css/all.css">
    <link rel="stylesheet" href="assets/jquerydatatable/datatables.min.css">
    <link rel="stylesheet" href="assets/jquerydatatable/DataTables-1.12.1/css/dataTables.bootstrap.min.css">
</head>

<body>
    <div class="card">
        <div class="card-header">
            <H6>DATA KODE REKENING</H6>
            <!-- Tombol Tambah KOde Rekening -->
            <button type="button" class="btn btn-success mt-2 btn-sm" data-bs-toggle="modal" data-bs-target="#tambahKodrek"><i class="fa-solid fa-plus"></i> Tambah
            </button>
            <a class="btn btn-info mt-2 btn-sm" type="button" href="kodrek/cetak.php" target="_blank">Cetak Laporan
            </a>
            <a class="btn btn-danger mt-2 btn-sm" type="button" href="kodrek/cetakexcel.php" target="_blank">Cetak Excel
            </a>
        </div>

        <div class="card-body">

            <!-- Awal Tabel KOde Rekening-->
            <table id="tabelKodrek" class="table table-responsive table-stripe table-bordered table-sm compact table-hover row-border">
                <thead class="table-secondary">
                    <tr>
                        <th class="text-center" width="5%">No</th>
                        <th class="text-center" width="5%">Kode 6</th>
                        <th class="text-center" width="25%">Uraian Kode 6</th>
                        <th class="text-center" width="5%">Kode 5</th>
                        <th class="text-center" width="20%">Uraian Kode 5</th>
                        <th class="text-center" width="5%">Kode 2</th>
                        <th class="text-center" width="10%">Uraian Kode 2</th>
                        <th class="text-center" width="5%">Kode 1</th>
                        <th class="text-center" width="10%">Uraian Kode 1</th>
                        <th class="text-center" width="10%">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $no = 1;
                    $data = mysqli_query($koneksi, "SELECT * FROM kodrek ORDER BY kd6 ASC");
                    while ($hasil = mysqli_fetch_array($data)) {
                        echo '
                            <tr>
                                <td class="text-center" width="5%">' . $no++ . '</td>
                                <td class="text-center" width="5%">' . substr($hasil['kd6'], 0, 1) . "."
                            . substr($hasil['kd6'], 1, 1) . "."
                            . substr($hasil['kd6'], 2, 2) . "."
                            . substr($hasil['kd6'], 4, 2) . "."
                            . substr($hasil['kd6'], 6, 2) . "."
                            . substr($hasil['kd6'], 8, 4) . '</td>
                                <td width="25%">' . $hasil['namakd6'] . '</td>
                                <td class="text-center">' . substr($hasil['kd5'], 0, 1) . "."
                            . substr($hasil['kd5'], 1, 1) . "."
                            . substr($hasil['kd5'], 2, 2) . "."
                            . substr($hasil['kd5'], 4, 2) . "."
                            . substr($hasil['kd5'], 6, 2) . '</td>
                                <td>' . $hasil['namakd5'] . '</td>
                                <td class="text-center" width="5%">' . $hasil['kd2'] . '</td>
                                <td>' . $hasil['namakd2'] . '</td>
                                <td class="text-center" width="5%">' . $hasil['kd1'] . '</td>
                                <td>' . $hasil['namakd1'] . '</td>
                                <td class="text-center">
                                <a type="button" class="ubahData" id=' . $hasil['idkd6'] . '> Ubah</a> |
                                <a type="button" id="hapusKodrek">Hapus</a>
                                </td>

                            </tr>
                    ';
                    }
                    ?>

                    <!-- Awal Modal Ubah Kode Rekening-->
                    <div class="modal fade" id="modalubahKodrek" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="ubahKodrekLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <form action="" method="post" id="updateForm">
                                    <div class="modal-header bg-warning">
                                        <h6 class="modal-title" id="ubahKodrekLabel">Ubah Kode Rekening</h6>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body" id="infoUpdate">

                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-success btn-sm" id="updateKodrek"><i class="fa-solid fa-floppy-disk"></i> Update</button>
                                        <button type="button" class="btn btn-danger btn-sm" data-bs-dismiss="modal"><i class="fa-regular fa-circle-xmark"></i> Tutup</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <!-- Akhir Modal Ubah Golongan-->
                </tbody>
            </table>
        </div>
        <!-- Akhir Tabel Golongan-->
    </div>
    </div>
    </div>

    <!-- Awal Modal Tambah Kode Rekening-->
    <div class="modal fade" id="tambahKodrek" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="tambahKodrekLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header bg-success text-white">
                    <h6 class="modal-title" id="tambahKodrekLabel">Tambah Kode Rekening</h6>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="kodrek/tambah.php" method="post">
                        <div class="mb-3">
                            <label for="idkd6" class="form-label" hidden>Id Kode Belanja</label>
                            <input type="text" class="form-control form-control-sm" id="idkd6" name="idkd6" placeholder="ID Kode 6" hidden>
                        </div>
                        <div class="mb-3">
                            <label for="kd6" class="form-label">Kode Belanja 6</label>
                            <input type="text" class="form-control form-control-sm" id="kd6" name="kd6" placeholder="Kode Belanja 6" maxlength="12" required>
                        </div>
                        <div class="mb-3">
                            <label for="namakd6" class="form-label">Uraian Kode Belanja 6</label>
                            <input type="text" class="form-control form-control-sm" id="namakd6" name="namakd6" placeholder="Uraian Kode Belanja 6" required>
                        </div>
                        <div class="mb-3">
                            <label for="kd5" class="form-label">Kode Belanja 5</label>
                            <input type="text" class="form-control form-control-sm" id="kd5" name="kd5" placeholder="Kode Belanja 5" maxlength="8" required>
                        </div>
                        <div class="mb-3">
                            <label for="namakd5" class="form-label">Uraian Kode Belanja 5</label>
                            <input type="text" class="form-control form-control-sm" id="namakd5" name="namakd5" placeholder="Uraian Kode Belanja 5" required>
                        </div>
                        <div class="mb-3">
                            <label for="kd4" class="form-label">Kode Belanja 4</label>
                            <input type="text" class="form-control form-control-sm" id="kd4" name="kd4" placeholder="Kode Belanja 4" maxlength="6" required>
                        </div>
                        <div class="mb-3">
                            <label for="namakd4" class="form-label">Uraian Kode Belanja 4</label>
                            <input type="text" class="form-control form-control-sm" id="namakd4" name="namakd4" placeholder="Uraian Kode Belanja 4" required>
                        </div>
                        <div class="mb-3">
                            <label for="kd3" class="form-label">Kode Belanja 3</label>
                            <input type="text" class="form-control form-control-sm" id="kd3" name="kd3" placeholder="Kode Belanja 3" maxlength="4" required>
                        </div>
                        <div class="mb-3">
                            <label for="namakd3" class="form-label">Uraian Kode Belanja 3</label>
                            <input type="text" class="form-control form-control-sm" id="namakd3" name="namakd3" placeholder="Uraian Kode Belanja 3" required>
                        </div>
                        <div class="mb-3">
                            <label for="kd2" class="form-label">Kode Belanja 2</label>
                            <input type="text" class="form-control form-control-sm" id="kd2" name="kd2" placeholder="Kode Belanja 2" maxlength="2" required>
                        </div>
                        <div class="mb-3">
                            <label for="namakd2" class="form-label">Uraian Kode Belanja 2</label>
                            <input type="text" class="form-control form-control-sm" id="namakd2" name="namakd2" placeholder="Uraian Kode Belanja 2" required>
                        </div>
                        <div class="mb-3">
                            <label for="kd1" class="form-label">Kode Belanja 1</label>
                            <input type="text" class="form-control form-control-sm" id="kd1" name="kd1" placeholder="Kode Belanja 1" maxlength="1" required>
                        </div>
                        <div class="mb-3">
                            <label for="namakd1" class="form-label">Uraian Kode Belanja 1</label>
                            <input type="text" class="form-control form-control-sm" id="namakd1" name="namakd1" placeholder="Uraian Kode Belanja 1" required>
                        </div>
                        <button type="submit" class="btn btn-success btn-sm" name="simpanKodrek"><i class="fa-solid fa-floppy-disk"></i> Simpan</button>
                        <button type="reset" class="btn btn-warning btn-sm"><i class="fa-solid fa-ban"></i> Batal</button>
                        <button type="button" class="btn btn-danger btn-sm" data-bs-dismiss="modal"><i class="fa-regular fa-circle-xmark"></i> Tutup</button>
                    </form>
                </div>
                <div class="modal-footer">
                </div>
            </div>
        </div>
    </div>
    <!-- Akhir Modal Tambah Kode Rekening-->

    <script type="text/javascript" src="assets/bootstrap-5.0.2-dist/js/bootstrap.bundle.min.js"></script>
    <script type="text/javascript" src="assets/jquery/jquery360.js"></script>
    <script type="text/javascript" src="assets/jquery/tools.js"></script>
    <script type="text/javascript" src="assets/jquerydatatable/datatables.min.js"></script>
    <script type="text/javascript" src="assets/jquerydatatable/DataTables-1.12.1/js/dataTables.bootstrap.min.js"></script>
    <script>
        $(document).ready(function() {
            $("#tabelKodrek").DataTable();

            //script update
            $(document).on('click', '.ubahData', function() {
                var edit_id = $(this).attr('id');
                $.ajax({
                    url: 'kodrek/ubah.php',
                    type: 'post',
                    data: {
                        edit_id: edit_id
                    },
                    success: function(data) {
                        $('#infoUpdate').html(data);
                        $('modalubahKodrek').modal('show');
                    }
                });
                $('#modalubahKodrek').modal('show');
            });
            //end script update

            //script simpan update
            $(document).on('click', '#updateKodrek', function() {
                $.ajax({
                    url: 'kodrek/simpanubah.php',
                    type: 'post',
                    data: $('#updateForm').serialize(),
                    success: function(data) {
                        $('#modalubahKodrek').modal('hide');
                        location.reload();
                    }
                });

            });
            //akhir script simpan update

            $('#hapusKodrek').click(function() {
                alert('Apakah Anda Yakin Akan Menghapus Data..........?');
            });
        });
    </script>
</body>

</html>

ini script ubah.php

<?php
include("../koneksi.php");

if (isset($_POST['edit_id'])) {

    $idkd6 = $_POST['edit_id'];
    $query = mysqli_query($koneksi, "SELECT * FROM kodrek WHERE idkd6 = '$idkd6'");
    while ($row = mysqli_fetch_array($query)) {
        $idkd6      = $row['idkd6'];
        $kd6        = $row['kd6'];
        $namakd6    = $row['namakd6'];
        $kd5      = $row['kd5'];
        $namakd5    = $row['namakd5'];
        $kd4      = $row['kd4'];
        $namakd4    = $row['namakd4'];
        $kd3      = $row['kd3'];
        $namakd3    = $row['namakd3'];
        $kd2      = $row['kd2'];
        $namakd2    = $row['namakd2'];
        $kd1      = $row['kd1'];
        $namakd1    = $row['namakd1'];
    }
}
?>

<input type="text" class="form-control form-control-sm" id="edit_id" name="edit_id" value="<?php echo $idkd6 ?>" readonly>

<label for="kd6" class="form-label">Kode Belanja 6</label>
<input type="text" class="form-control form-control-sm" id="kd6" name="kd6" placeholder="Kode Belanja 6" maxlength="12" required value="<?php echo $kd6 ?>">

<label for="namakd6" class="form-label">Uraian Kode Belanja 6</label>
<input type="text" class="form-control form-control-sm" id="namakd6" name="namakd6" placeholder="Uraian Kode Belanja 6" required value="<?php echo $namakd6 ?>">

<label for="kd5" class="form-label">Kode Belanja 5</label>
<input type="text" class="form-control form-control-sm" id="kd5" name="kd5" placeholder="Kode Belanja 5" maxlength="8" required value="<?php echo $kd5 ?>">

<label for="namakd5" class="form-label">Uraian Kode Belanja 5</label>
<input type="text" class="form-control form-control-sm" id="namakd5" name="namakd5" placeholder="Uraian Kode Belanja 5" required value="<?php echo $namakd5 ?>">

<label for="kd4" class="form-label">Kode Belanja 4</label>
<input type="text" class="form-control form-control-sm" id="kd4" name="kd4" placeholder="Kode Belanja 4" maxlength="8" required value="<?php echo $kd4 ?>">

<label for="namakd4" class="form-label">Uraian Kode Belanja 4</label>
<input type="text" class="form-control form-control-sm" id="namakd4" name="namakd4" placeholder="Uraian Kode Belanja 4" required value="<?php echo $namakd4 ?>">

<label for="kd3" class="form-label">Kode Belanja 3</label>
<input type="text" class="form-control form-control-sm" id="kd3" name="kd3" placeholder="Kode Belanja 3" maxlength="8" required value="<?php echo $kd3 ?>">

<label for="namakd3" class="form-label">Uraian Kode Belanja 3</label>
<input type="text" class="form-control form-control-sm" id="namakd3" name="namakd3" placeholder="Uraian Kode Belanja 3" required value="<?php echo $namakd3 ?>">

<label for="kd2" class="form-label">Kode Belanja 2</label>
<input type="text" class="form-control form-control-sm" id="kd2" name="kd2" placeholder="Kode Belanja 2" maxlength="8" required value="<?php echo $kd2 ?>">

<label for="namakd2" class="form-label">Uraian Kode Belanja 2</label>
<input type="text" class="form-control form-control-sm" id="namakd2" name="namakd2" placeholder="Uraian Kode Belanja 2" required value="<?php echo $namakd2 ?>">

<label for="kd1" class="form-label">Kode Belanja 1</label>
<input type="text" class="form-control form-control-sm" id="kd1" name="kd1" placeholder="Kode Belanja 1" maxlength="8" required value="<?php echo $kd1 ?>">

<label for="namakd1" class="form-label">Uraian Kode Belanja 1</label>
<input type="text" class="form-control form-control-sm" id="namakd1" name="namakd1" placeholder="Uraian Kode Belanja 1" required value="<?php echo $namakd1 ?>">

ini script simpanubah.php

<?php
include("koneksi.php");

$idkd6      = $_POST['idkd6'];
$kd6        = $_POST['kd6'];
$namakd6    = $_POST['namakd6'];
$kd5        = $_POST['kd5'];
$namakd5    = $_POST['namakd5'];
$kd4        = $_POST['kd4'];
$namakd4    = $_POST['namakd4'];
$kd3        = $_POST['kd3'];
$namakd3    = $_POST['namakd3'];
$kd2        = $_POST['kd2'];
$namakd2    = $_POST['namakd2'];
$kd1        = $_POST['kd1'];
$namakd1    = $_POST['namakd1'];

$sql = mysqli_query($koneksi, "UPDATE kodrek SET kd6='".$kd6."' WHERE idkd6='".$idkd6."'");

pada saat klik tmbol ubah,data masuk ke modal edit.tapi saat di simpan,tidak ada data yang ter update.mohon bantuannya.

avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Diperbarui 2 tahun yang lalu

6 Jawaban:

<div>Pasti sudah ketemu jawabannya ya kalo sekarang?<br><br></div><pre>//Bagian form mu

$idkd6 = $_POST['idkd6']; //&lt;------- $kd6 = $_POST['kd6']; $namakd6 = $_POST['namakd6'];

//Bagian simpanubah.php<pre>&lt;input type="text" class="form-control form-control-sm" id="edit_id" name="edit_id" value="&lt;?php echo $idkd6 ?&gt;" readonly&gt;</pre></pre><div><br></div><div><br>Yang ada [name='edit_id'] dan bukan [name='idkd6']</div><div><br></div><div><br></div><div><br><br></div>

avatar GrennKren
@GrennKren

62 Kontribusi 47 Poin

Dipost 2 tahun yang lalu

Tanggapan

di samain jga masih sama kak.tidak bisa terupdate.

<div>masih sama kak.di samain nilainya pun tetap gak bisa ke update<br><br></div><pre>&lt;?php include("koneksi.php");

?&gt;

&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt;

&lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;title&gt;Kode Rekening&lt;/title&gt; &lt;link rel="stylesheet" href="assets/bootstrap-5.0.2-dist/css/bootstrap.min.css"&gt; &lt;link rel="stylesheet" href="assets/jquery/jquery360.js"&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;link rel="stylesheet" href="assets/fontawesome620/css/all.css"&gt; &lt;link rel="stylesheet" href="assets/jquerydatatable/datatables.min.css"&gt; &lt;link rel="stylesheet" href="assets/jquerydatatable/DataTables-1.12.1/css/dataTables.bootstrap.min.css"&gt; &lt;/head&gt;

&lt;body&gt; &lt;div class="card"&gt; &lt;div class="card-header"&gt; &lt;H6&gt;DATA KODE REKENING&lt;/H6&gt; &lt;!-- Tombol Tambah KOde Rekening --&gt; &lt;button type="button" class="btn btn-success mt-2 btn-sm" data-bs-toggle="modal" data-bs-target="#tambahKodrek"&gt;&lt;i class="fa-solid fa-plus"&gt;&lt;/i&gt; Tambah &lt;/button&gt; &lt;a class="btn btn-info mt-2 btn-sm" type="button" href="kodrek/cetak.php" target="_blank"&gt;Cetak Laporan &lt;/a&gt; &lt;a class="btn btn-danger mt-2 btn-sm" type="button" href="kodrek/cetakexcel.php" target="_blank"&gt;Cetak Excel &lt;/a&gt; &lt;/div&gt;

    &amp;lt;div class=&quot;card-body&quot;&amp;gt;

        &amp;lt;!-- Awal Tabel KOde Rekening--&amp;gt;
        &amp;lt;table id=&quot;tabelKodrek&quot; class=&quot;table table-responsive table-stripe table-bordered table-sm compact table-hover row-border&quot;&amp;gt;
            &amp;lt;thead class=&quot;table-secondary&quot;&amp;gt;
                &amp;lt;tr&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;No&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;Kode 6&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;25%&quot;&amp;gt;Uraian Kode 6&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;Kode 5&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;20%&quot;&amp;gt;Uraian Kode 5&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;Kode 2&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;10%&quot;&amp;gt;Uraian Kode 2&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;Kode 1&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;10%&quot;&amp;gt;Uraian Kode 1&amp;lt;/th&amp;gt;
                    &amp;lt;th class=&quot;text-center&quot; width=&quot;10%&quot;&amp;gt;Aksi&amp;lt;/th&amp;gt;
                &amp;lt;/tr&amp;gt;
            &amp;lt;/thead&amp;gt;
            &amp;lt;tbody&amp;gt;
                &amp;lt;?php
                $no = 1;
                $data = mysqli_query($koneksi, &quot;SELECT * FROM kodrek ORDER BY kd6 ASC&quot;);
                while ($hasil = mysqli_fetch_array($data)) {
                    echo &#039;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;&#039; . $no++ . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;&#039; . substr($hasil[&#039;kd6&#039;], 0, 1) . &quot;.&quot;
                        . substr($hasil[&#039;kd6&#039;], 1, 1) . &quot;.&quot;
                        . substr($hasil[&#039;kd6&#039;], 2, 2) . &quot;.&quot;
                        . substr($hasil[&#039;kd6&#039;], 4, 2) . &quot;.&quot;
                        . substr($hasil[&#039;kd6&#039;], 6, 2) . &quot;.&quot;
                        . substr($hasil[&#039;kd6&#039;], 8, 4) . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td width=&quot;25%&quot;&amp;gt;&#039; . $hasil[&#039;namakd6&#039;] . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td class=&quot;text-center&quot;&amp;gt;&#039; . substr($hasil[&#039;kd5&#039;], 0, 1) . &quot;.&quot;
                        . substr($hasil[&#039;kd5&#039;], 1, 1) . &quot;.&quot;
                        . substr($hasil[&#039;kd5&#039;], 2, 2) . &quot;.&quot;
                        . substr($hasil[&#039;kd5&#039;], 4, 2) . &quot;.&quot;
                        . substr($hasil[&#039;kd5&#039;], 6, 2) . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;&#039; . $hasil[&#039;namakd5&#039;] . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;&#039; . $hasil[&#039;kd2&#039;] . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;&#039; . $hasil[&#039;namakd2&#039;] . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td class=&quot;text-center&quot; width=&quot;5%&quot;&amp;gt;&#039; . $hasil[&#039;kd1&#039;] . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td&amp;gt;&#039; . $hasil[&#039;namakd1&#039;] . &#039;&amp;lt;/td&amp;gt;
                            &amp;lt;td class=&quot;text-center&quot;&amp;gt;
                            &amp;lt;a type=&quot;button&quot; class=&quot;ubahData&quot; id=&#039; . $hasil[&#039;idkd6&#039;] . &#039;&amp;gt; Ubah&amp;lt;/a&amp;gt; |
                            &amp;lt;a type=&quot;button&quot; id=&quot;hapusKodrek&quot;&amp;gt;Hapus&amp;lt;/a&amp;gt;
                            &amp;lt;/td&amp;gt;
                            
                        &amp;lt;/tr&amp;gt;
                &#039;;
                }
                ?&amp;gt;

                &amp;lt;!-- Awal Modal Ubah Kode Rekening--&amp;gt;
                &amp;lt;div class=&quot;modal fade&quot; id=&quot;modalubahKodrek&quot; data-bs-backdrop=&quot;static&quot; data-bs-keyboard=&quot;false&quot; tabindex=&quot;-1&quot; aria-labelledby=&quot;ubahKodrekLabel&quot; aria-hidden=&quot;true&quot;&amp;gt;
                    &amp;lt;div class=&quot;modal-dialog&quot;&amp;gt;
                        &amp;lt;div class=&quot;modal-content&quot;&amp;gt;
                            &amp;lt;form action=&quot;&quot; method=&quot;post&quot; id=&quot;updateForm&quot;&amp;gt;
                                &amp;lt;div class=&quot;modal-header bg-warning&quot;&amp;gt;
                                    &amp;lt;h6 class=&quot;modal-title&quot; id=&quot;ubahKodrekLabel&quot;&amp;gt;Ubah Kode Rekening&amp;lt;/h6&amp;gt;
                                    &amp;lt;button type=&quot;button&quot; class=&quot;btn-close&quot; data-bs-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&amp;gt;&amp;lt;/button&amp;gt;
                                &amp;lt;/div&amp;gt;
                                &amp;lt;div class=&quot;modal-body&quot; id=&quot;infoUpdate&quot;&amp;gt;

                                &amp;lt;/div&amp;gt;
                                &amp;lt;div class=&quot;modal-footer&quot;&amp;gt;
                                    &amp;lt;button type=&quot;button&quot; class=&quot;btn btn-success btn-sm&quot; id=&quot;updateKodrek&quot;&amp;gt;&amp;lt;i class=&quot;fa-solid fa-floppy-disk&quot;&amp;gt;&amp;lt;/i&amp;gt; Update&amp;lt;/button&amp;gt;
                                    &amp;lt;button type=&quot;button&quot; class=&quot;btn btn-danger btn-sm&quot; data-bs-dismiss=&quot;modal&quot;&amp;gt;&amp;lt;i class=&quot;fa-regular fa-circle-xmark&quot;&amp;gt;&amp;lt;/i&amp;gt; Tutup&amp;lt;/button&amp;gt;
                                &amp;lt;/div&amp;gt;
                            &amp;lt;/form&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;!-- Akhir Modal Ubah Golongan--&amp;gt;
            &amp;lt;/tbody&amp;gt;
        &amp;lt;/table&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;!-- Akhir Tabel Golongan--&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;!-- Awal Modal Tambah Kode Rekening--&amp;gt;
&amp;lt;div class=&quot;modal fade&quot; id=&quot;tambahKodrek&quot; data-bs-backdrop=&quot;static&quot; data-bs-keyboard=&quot;false&quot; tabindex=&quot;-1&quot; aria-labelledby=&quot;tambahKodrekLabel&quot; aria-hidden=&quot;true&quot;&amp;gt;
    &amp;lt;div class=&quot;modal-dialog&quot;&amp;gt;
        &amp;lt;div class=&quot;modal-content&quot;&amp;gt;
            &amp;lt;div class=&quot;modal-header bg-success text-white&quot;&amp;gt;
                &amp;lt;h6 class=&quot;modal-title&quot; id=&quot;tambahKodrekLabel&quot;&amp;gt;Tambah Kode Rekening&amp;lt;/h6&amp;gt;
                &amp;lt;button type=&quot;button&quot; class=&quot;btn-close&quot; data-bs-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&amp;gt;&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class=&quot;modal-body&quot;&amp;gt;
                &amp;lt;form action=&quot;kodrek/tambah.php&quot; method=&quot;post&quot;&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;idkd6&quot; class=&quot;form-label&quot; hidden&amp;gt;Id Kode Belanja&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;idkd6&quot; name=&quot;idkd6&quot; placeholder=&quot;ID Kode 6&quot; hidden&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;kd6&quot; class=&quot;form-label&quot;&amp;gt;Kode Belanja 6&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;kd6&quot; name=&quot;kd6&quot; placeholder=&quot;Kode Belanja 6&quot; maxlength=&quot;12&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;namakd6&quot; class=&quot;form-label&quot;&amp;gt;Uraian Kode Belanja 6&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;namakd6&quot; name=&quot;namakd6&quot; placeholder=&quot;Uraian Kode Belanja 6&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;kd5&quot; class=&quot;form-label&quot;&amp;gt;Kode Belanja 5&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;kd5&quot; name=&quot;kd5&quot; placeholder=&quot;Kode Belanja 5&quot; maxlength=&quot;8&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;namakd5&quot; class=&quot;form-label&quot;&amp;gt;Uraian Kode Belanja 5&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;namakd5&quot; name=&quot;namakd5&quot; placeholder=&quot;Uraian Kode Belanja 5&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;kd4&quot; class=&quot;form-label&quot;&amp;gt;Kode Belanja 4&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;kd4&quot; name=&quot;kd4&quot; placeholder=&quot;Kode Belanja 4&quot; maxlength=&quot;6&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;namakd4&quot; class=&quot;form-label&quot;&amp;gt;Uraian Kode Belanja 4&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;namakd4&quot; name=&quot;namakd4&quot; placeholder=&quot;Uraian Kode Belanja 4&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;kd3&quot; class=&quot;form-label&quot;&amp;gt;Kode Belanja 3&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;kd3&quot; name=&quot;kd3&quot; placeholder=&quot;Kode Belanja 3&quot; maxlength=&quot;4&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;namakd3&quot; class=&quot;form-label&quot;&amp;gt;Uraian Kode Belanja 3&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;namakd3&quot; name=&quot;namakd3&quot; placeholder=&quot;Uraian Kode Belanja 3&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;kd2&quot; class=&quot;form-label&quot;&amp;gt;Kode Belanja 2&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;kd2&quot; name=&quot;kd2&quot; placeholder=&quot;Kode Belanja 2&quot; maxlength=&quot;2&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;namakd2&quot; class=&quot;form-label&quot;&amp;gt;Uraian Kode Belanja 2&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;namakd2&quot; name=&quot;namakd2&quot; placeholder=&quot;Uraian Kode Belanja 2&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;kd1&quot; class=&quot;form-label&quot;&amp;gt;Kode Belanja 1&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;kd1&quot; name=&quot;kd1&quot; placeholder=&quot;Kode Belanja 1&quot; maxlength=&quot;1&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;namakd1&quot; class=&quot;form-label&quot;&amp;gt;Uraian Kode Belanja 1&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;namakd1&quot; name=&quot;namakd1&quot; placeholder=&quot;Uraian Kode Belanja 1&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;button type=&quot;submit&quot; class=&quot;btn btn-success btn-sm&quot; name=&quot;simpanKodrek&quot;&amp;gt;&amp;lt;i class=&quot;fa-solid fa-floppy-disk&quot;&amp;gt;&amp;lt;/i&amp;gt; Simpan&amp;lt;/button&amp;gt;
                    &amp;lt;button type=&quot;reset&quot; class=&quot;btn btn-warning btn-sm&quot;&amp;gt;&amp;lt;i class=&quot;fa-solid fa-ban&quot;&amp;gt;&amp;lt;/i&amp;gt; Batal&amp;lt;/button&amp;gt;
                    &amp;lt;button type=&quot;button&quot; class=&quot;btn btn-danger btn-sm&quot; data-bs-dismiss=&quot;modal&quot;&amp;gt;&amp;lt;i class=&quot;fa-regular fa-circle-xmark&quot;&amp;gt;&amp;lt;/i&amp;gt; Tutup&amp;lt;/button&amp;gt;
                &amp;lt;/form&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class=&quot;modal-footer&quot;&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;!-- Akhir Modal Tambah Kode Rekening--&amp;gt;

&amp;lt;script type=&quot;text/javascript&quot; src=&quot;assets/bootstrap-5.0.2-dist/js/bootstrap.bundle.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;assets/jquery/jquery360.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;assets/jquery/tools.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;assets/jquerydatatable/datatables.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;assets/jquerydatatable/DataTables-1.12.1/js/dataTables.bootstrap.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
    $(document).ready(&lt;em&gt;function&lt;/em&gt;() {
        $(&quot;#tabelKodrek&quot;).DataTable();


        //script update
        $(document).on(&#039;click&#039;, &#039;.ubahData&#039;, &lt;em&gt;function&lt;/em&gt;() {
            &lt;em&gt;var&lt;/em&gt; edit_id = $(this).attr(&#039;id&#039;);
            $.ajax({
                url: &#039;kodrek/ubah.php&#039;,
                type: &#039;post&#039;,
                data: {
                    edit_id: edit_id
                },
                success: &lt;em&gt;function&lt;/em&gt;(&lt;em&gt;data&lt;/em&gt;) {
                    $(&#039;#infoUpdate&#039;).html(data);
                    $(&#039;modalubahKodrek&#039;).modal(&#039;show&#039;);
                }
            });
            $(&#039;#modalubahKodrek&#039;).modal(&#039;show&#039;);
        });
        //end script update


        //script simpan update
        $(document).on(&#039;click&#039;, &#039;#updateKodrek&#039;, &lt;em&gt;function&lt;/em&gt;() {
            $.ajax({
                url: &#039;kodrek/simpanubah.php&#039;,
                type: &#039;post&#039;,
                data: $(&#039;#updateForm&#039;).serialize(),
                success: &lt;em&gt;function&lt;/em&gt;(&lt;em&gt;data&lt;/em&gt;) {
                    $(&#039;#modalubahKodrek&#039;).modal(&#039;hide&#039;);
                    location.reload();
                }
            });

        });
        //akhir script simpan update

        $(&#039;#hapusKodrek&#039;).click(&lt;em&gt;function&lt;/em&gt;() {
            alert(&#039;Apakah Anda Yakin Akan Menghapus Data..........?&#039;);
        });
    });
&amp;lt;/script&amp;gt;

&lt;/body&gt;

&lt;/html&gt;</pre><div><br>script ubah.php<br><br></div><pre>&lt;?php include("../koneksi.php");

if (isset($_POST['edit_id'])) {

$idkd6 = $_POST[&#039;edit_id&#039;];
$query = mysqli_query($koneksi, &quot;SELECT * FROM kodrek WHERE idkd6 = &#039;$idkd6&#039;&quot;);
while ($row = mysqli_fetch_array($query)) {
    $idkd6      = $row[&#039;idkd6&#039;];
    $kd6        = $row[&#039;kd6&#039;];
    $namakd6    = $row[&#039;namakd6&#039;];
    $kd5      = $row[&#039;kd5&#039;];
    $namakd5    = $row[&#039;namakd5&#039;];
    $kd4      = $row[&#039;kd4&#039;];
    $namakd4    = $row[&#039;namakd4&#039;];
    $kd3      = $row[&#039;kd3&#039;];
    $namakd3    = $row[&#039;namakd3&#039;];
    $kd2      = $row[&#039;kd2&#039;];
    $namakd2    = $row[&#039;namakd2&#039;];
    $kd1      = $row[&#039;kd1&#039;];
    $namakd1    = $row[&#039;namakd1&#039;];
}

} ?&gt;

&lt;input type="text" class="form-control form-control-sm" id="idkd6" name="idkd6" value="&lt;?php echo $idkd6 ?&gt;" readonly&gt;

&lt;label for="kd6" class="form-label"&gt;Kode Belanja 6&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="kd6" name="kd6" placeholder="Kode Belanja 6" maxlength="12" required value="&lt;?php echo $kd6 ?&gt;"&gt;

&lt;label for="namakd6" class="form-label"&gt;Uraian Kode Belanja 6&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="namakd6" name="namakd6" placeholder="Uraian Kode Belanja 6" required value="&lt;?php echo $namakd6 ?&gt;"&gt;

&lt;label for="kd5" class="form-label"&gt;Kode Belanja 5&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="kd5" name="kd5" placeholder="Kode Belanja 5" maxlength="8" required value="&lt;?php echo $kd5 ?&gt;"&gt;

&lt;label for="namakd5" class="form-label"&gt;Uraian Kode Belanja 5&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="namakd5" name="namakd5" placeholder="Uraian Kode Belanja 5" required value="&lt;?php echo $namakd5 ?&gt;"&gt;

&lt;label for="kd4" class="form-label"&gt;Kode Belanja 4&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="kd4" name="kd4" placeholder="Kode Belanja 4" maxlength="8" required value="&lt;?php echo $kd4 ?&gt;"&gt;

&lt;label for="namakd4" class="form-label"&gt;Uraian Kode Belanja 4&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="namakd4" name="namakd4" placeholder="Uraian Kode Belanja 4" required value="&lt;?php echo $namakd4 ?&gt;"&gt;

&lt;label for="kd3" class="form-label"&gt;Kode Belanja 3&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="kd3" name="kd3" placeholder="Kode Belanja 3" maxlength="8" required value="&lt;?php echo $kd3 ?&gt;"&gt;

&lt;label for="namakd3" class="form-label"&gt;Uraian Kode Belanja 3&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="namakd3" name="namakd3" placeholder="Uraian Kode Belanja 3" required value="&lt;?php echo $namakd3 ?&gt;"&gt;

&lt;label for="kd2" class="form-label"&gt;Kode Belanja 2&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="kd2" name="kd2" placeholder="Kode Belanja 2" maxlength="8" required value="&lt;?php echo $kd2 ?&gt;"&gt;

&lt;label for="namakd2" class="form-label"&gt;Uraian Kode Belanja 2&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="namakd2" name="namakd2" placeholder="Uraian Kode Belanja 2" required value="&lt;?php echo $namakd2 ?&gt;"&gt;

&lt;label for="kd1" class="form-label"&gt;Kode Belanja 1&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="kd1" name="kd1" placeholder="Kode Belanja 1" maxlength="8" required value="&lt;?php echo $kd1 ?&gt;"&gt;

&lt;label for="namakd1" class="form-label"&gt;Uraian Kode Belanja 1&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm" id="namakd1" name="namakd1" placeholder="Uraian Kode Belanja 1" required value="&lt;?php echo $namakd1 ?&gt;"&gt; <br></pre><div><br>script simpanubah.php<br><br></div><pre>&lt;?php include("koneksi.php");

$idkd6 = $_POST['idkd6']; $kd6 = $_POST['kd6']; $namakd6 = $_POST['namakd6']; $kd5 = $_POST['kd5']; $namakd5 = $_POST['namakd5']; $kd4 = $_POST['kd4']; $namakd4 = $_POST['namakd4']; $kd3 = $_POST['kd3']; $namakd3 = $_POST['namakd3']; $kd2 = $_POST['kd2']; $namakd2 = $_POST['namakd2']; $kd1 = $_POST['kd1']; $namakd1 = $_POST['namakd1'];

$sql = mysqli_query($koneksi, "UPDATE kodrek SET kd6='".$kd6."' WHERE idkd6='".$idkd6."'"); <br></pre><div><br>tapi anehnya,saat mncul modal ubah,semua nilai ada di form ubahnya<br><br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image.png&quot;,&quot;filesize&quot;:29254,&quot;height&quot;:843,&quot;url&quot;:&quot;https://i.ibb.co/GxvQwzQ/image.png&quot;,&quot;width&quot;:619}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/GxvQwzQ/image.png" width="619" height="843"><figcaption class="attachment__caption"><span class="attachment__name">image.png</span></figcaption></figure><br>mohon pencerahannya kak.maaf saya baru belajar<br><br></div>

avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

<div>Tadi aku mengira karena tombol button nya tapi rupanya bukan.<br><br>Kalau gitu ya coba aja lakukan debug di query nya.<br>Jika lewat DevTools browser. Tekan tombol F12 biasanya untuk chrome dan Firefox. lalu di bagian tab network nya itu bakal keliatan proses ajax nya ketika kita nekan tombol di form.<br><br>Tapi pastikan di centang "Preserve Log" karena di ajax mu ada perintah location.reload , yang mana jika halaman ke refresh yg di DevTools bakal ikutan ke reset.<br><br>===============<br><br>Kalau pengen lewat koding, di dalam file&nbsp; kodrek/simpanubah.php mu, di akhirnya tambahin</div><pre>if(!$sql){ echo "Terjadi kesalahan : " . mysqli_error($koneksi); }</pre><div><br>Lalu di ajax yang bersangkutan</div><pre>$(document).on('click', '#updateKodrek', <em>function</em>(event) { event.preventDefault(); //&lt;--------- $.ajax({ url: 'kodrek/simpanubah.php', type: 'post', data: $('#updateForm').serialize(), success: <em>function</em>(data) { &lt;--------- if(data.length &gt; 0){
alert(data)
}else{ $('#modalubahKodrek').modal('hide'); location.reload(); } } }); });</pre><div><br>Fungsinya buat mengecek jika kodrek/simpanubah.php ada yang di echo, maka di manggil apa isi nya melalui alert(data)</div>

avatar GrennKren
@GrennKren

62 Kontribusi 47 Poin

Dipost 2 tahun yang lalu

Tanggapan

masih sama kak.saya masukin kodingnya jg gak ada alert yg mncul

<div><br>script tmbol<br><br></div><pre> $(document).on('click', '#updateKodrek', <em>function</em>() { event.preventDefault(); $.ajax({ url: 'kodrek/simpanubah.php', type: 'post', data: $('#updateForm').serialize(), success: <em>function</em>(<em>data</em>) { $('#modalubahKodrek').modal('hide'); location.reload(); } });

        });&lt;/pre&gt;&lt;div&gt;&lt;br&gt;script simpanubah.php&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;pre&gt; &amp;lt;?php

include("koneksi.php");

$idkd6 = $_POST['idkd6']; $kd6 = $_POST['kd6']; $namakd6 = $_POST['namakd6']; $kd5 = $_POST['kd5']; $namakd5 = $_POST['namakd5']; $kd4 = $_POST['kd4']; $namakd4 = $_POST['namakd4']; $kd3 = $_POST['kd3']; $namakd3 = $_POST['namakd3']; $kd2 = $_POST['kd2']; $namakd2 = $_POST['namakd2']; $kd1 = $_POST['kd1']; $namakd1 = $_POST['namakd1'];

$sql = mysqli_query($koneksi, "UPDATE kodrek SET kd6='".$kd6."' WHERE idkd6='".$idkd6."'");

if(!$sql){ echo "Terjadi Kesalahan : " . mysqli_error($koneksi); }</pre><div><br>ss debug<br><br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image.png&quot;,&quot;filesize&quot;:99515,&quot;height&quot;:899,&quot;url&quot;:&quot;https://i.ibb.co/FBTBS7H/image.png&quot;,&quot;width&quot;:1731}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/FBTBS7H/image.png" width="1731" height="899"><figcaption class="attachment__caption"><span class="attachment__name">image.png</span></figcaption></figure><br><br><br><br></div>

avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

Tanggapan

Kamu ga ada parameter event di dalam ('click', '#updateKodrek', function(event)

jadinya terjadi error dan terhenti sebelum menjalakankan ajax.

Atau hapus aja baris event.PreventDefault, soalnya ga ada hubungan nya ternyata ama kendalanya

<div>Kalau sudah di hapus event.preventDefault nya.</div><pre>$sql = mysqli_query($koneksi, "UPDATE kodrek SET kd6='".$kd6."' WHERE idkd6='".$idkd6."'");

echo "test"; //&lt;-------

if(!$sql){ echo "Terjadi Kesalahan : " . mysqli_error($koneksi); }</pre><div><br>Bukan cara yang cantik, cuman memastikan aja jika yang diubah beneran file yang dimaksud dan bisa ditangkep melalui ajax.</div>

avatar GrennKren
@GrennKren

62 Kontribusi 47 Poin

Dipost 2 tahun yang lalu

Tanggapan

masih sama kak,saya masukin line echonya,saat klik simpan,gak muncul tulisan testnya.maaf ya kak saya banyak nanya.

<div>ini hasil scriptnya<br><br></div><pre>$sql = mysqli_query($koneksi, "UPDATE kodrek SET kd6='".$kd6."' WHERE idkd6='".$idkd6."'");

echo "test";

if(!$sql){ echo "Terjadi Kesalahan : " . mysqli_error($koneksi); }</pre><div><br></div>

avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

Tanggapan

ya gak bisa ngeliat alert nya soalnya ajax mu kan belum diubah. gak ada pengecekan data.length > 0

Login untuk ikut Jawaban