halaman tidak tereload sehingga tabel tidak terupdate

Selamat Sore, saya punya script kode kurang lebih seperti ini:

function getDetailUser(ubahid) {
            $('#ubahidUser').val(ubahid);
            $.ajax({
                url: 'user/ubah.php',
                type: 'post',
                data: {
                    ubahid: ubahid
                },
                success: function(data, status) {
                    var userId = JSON.parse(data);
                    $('#ubahidUser').val(userId.idUser);
                    $('#ubahuserName').val(userId.userName);
                    $('#ubahpassword').val(userId.password);
                    $('select[name = ubahidUker]').val(userId.idUker);
                    $('#ubahidUker').selectpicker('refresh');
                    $('#ubahlevelUser').val(userId.levelUser);
                },
            });
            $('#modalubahUser').modal('show');
        };

        $(document).on('click', '#updateUser', function() {
            var idUser = $('#ubahidUser').val();
            var userName = $('#ubahuserName').val();
            var password = $('#ubahpassword').val();
            var idUker = $('#ubahidUker').val();
            var levelUser = $('#ubahlevelUser').val();
            $.ajax({
                url: 'user/update.php',
                type: 'post',
                data: {
                    idUserUpdate: idUser,
                    userNameUpdate: userName,
                    passwordUpdate: password,
                    idUkerUpdate: idUker,
                    levelUserUpdate: levelUser
                },
                success: function(data, status) {
                        console.log(status);
                }
            });
            $('#modalubahUser').modal('hide');
        });

ketika saya klik #updateUser, data terupdate akan tetapi tabel tidak ter reload.ketika saya refresh halaman, muncul alert seperti ini:

image.png

kira-kira apa yang menyebabkan ini terjadi ya?

avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Diperbarui 2 tahun yang lalu

Tanggapan

tujuannya mau apa? kendalanya seperti apa? apa yang sudah dilakukan? biasakan buat pertanyaan sedetail mungkin agar bisa dipahami oleh member lain yang mau membantu.

mohon maaf kak jika pertanyaan dan kendala saya kurang jelas.saya sudah uraikan lagi kendala saya.semoga berkenan membantu.

3 Jawaban:

<pre><em>function</em> getDetailUser(<em>ubahid</em>) { $('#ubahidUser').val(ubahid); $.ajax({ url: 'user/ubah.php', type: 'post', data: { ubahid: ubahid }, success: <em>function</em>(<em>data</em>, <em>status</em>) { <em>var</em> userId = JSON.parse(data); $('#ubahidUser').val(userId.idUser); $('#ubahuserName').val(userId.userName); $('#ubahpassword').val(userId.password); $('select[name = ubahidUker]').val(userId.idUker); $('#ubahidUker').selectpicker('refresh'); $('#ubahlevelUser').val(userId.levelUser); }, }); $('#modalubahUser').modal('show'); };

    $(document).on(&#039;click&#039;, &#039;#updateUser&#039;, &lt;em&gt;function&lt;/em&gt;() {
        &lt;em&gt;var&lt;/em&gt; idUser = $(&#039;#ubahidUser&#039;).val();
        &lt;em&gt;var&lt;/em&gt; userName = $(&#039;#ubahuserName&#039;).val();
        &lt;em&gt;var&lt;/em&gt; password = $(&#039;#ubahpassword&#039;).val();
        &lt;em&gt;var&lt;/em&gt; idUker = $(&#039;#ubahidUker&#039;).val();
        &lt;em&gt;var&lt;/em&gt; levelUser = $(&#039;#ubahlevelUser&#039;).val();
        $.ajax({
            url: &#039;user/update.php&#039;,
            type: &#039;post&#039;,
            data: {
                idUserUpdate: idUser,
                userNameUpdate: userName,
                passwordUpdate: password,
                idUkerUpdate: idUker,
                levelUserUpdate: levelUser
            },
            success: &lt;em&gt;function&lt;/em&gt;(&lt;em&gt;data&lt;/em&gt;, &lt;em&gt;status&lt;/em&gt;) {
                location.reload();
            }
        });
        $(&#039;#modalubahUser&#039;).modal(&#039;hide&#039;);
    });&lt;/pre&gt;
avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

Jawaban Terpilih

<div>#updateUser itu sebuah tag hyperlink? Coba tambahin di eventlistener nya preventDefault. &nbsp;<br><br></div><pre>$(document).on('click', '#updateUser', <em>function</em>(event) { event.preventDefault() .. .</pre>

avatar GrennKren
@GrennKren

62 Kontribusi 47 Poin

Dipost 2 tahun yang lalu

Tanggapan

bukan hyperlink kak.tapi tombol untuk menyimpan data di modal ubah data.sudah saya rinci kendala saya di bawah kak.smoga berkenan membantu.

<div>mohon maaf kak @hanafi.pertanyaan dan kendala saya jika kurang jelas.saya takut pertanyaan saya terlalu panjang.tapi saya coba diuraikan lagi.smoga berkenan membantu.<br><br>saya punya page dengan tabel kurang lebih seperti ini:<br><br></div><pre>&lt;div class="card"&gt; &lt;div class="card-header"&gt; &lt;H6&gt;DATA USER&lt;/H6&gt; &lt;!-- Tombol Tambah User --&gt; &lt;button type="button" class="btn btn-success mt-2 btn-sm" data-bs-toggle="modal" data-bs-target="#modaltambahUser"&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="user/cetak.php" target="_blank"&gt;Cetak Laporan &lt;/a&gt; &lt;a class="btn btn-danger mt-2 btn-sm" type="button" href="user/cetakexcel.php" target="_blank"&gt;Cetak Excel &lt;/a&gt; &lt;/div&gt; &lt;div class="card-body"&gt; &lt;table id="example" class="table table-responsive table-sm table-bordered table-striped"&gt; &lt;thead class="table-secondary"&gt; &lt;tr&gt; &lt;th class="text-center" width="5%"&gt;No&lt;/th&gt; &lt;th class="text-center" width="20%"&gt;Username&lt;/th&gt; &lt;th class="text-center" width="50%"&gt;Unit Kerja&lt;/th&gt; &lt;th class="text-center" width="20%"&gt;Aksi&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php $no = 1; $query = mysqli_query($koneksi, "SELECT * FROM user INNER JOIN uker ON user.idUker=uker.idUker ORDER BY idUser ASC"); while ($hasil = mysqli_fetch_array($query)) { echo '&lt;tr&gt; &lt;td class="text-center"&gt;' . $no++ . '&lt;/td&gt; &lt;td&gt;' . $hasil['userName'] . '&lt;/td&gt; &lt;td&gt;' . $hasil['namaUker'] . '&lt;/td&gt; &lt;td class="text-center"&gt; &lt;button id="btnubahUser" type="button" class="btn btn-warning btn-sm" onclick="getDetailUser(' . $hasil['idUser'] . ')"&gt;Ubah&lt;/button&gt; &lt;button type="button" class="btn btn-danger btn-sm" onclick="hapusUser(' . $hasil['idUser'] . ')"&gt;Hapus&lt;/button&gt; &lt;/td&gt; &lt;/tr&gt;'; } ?&gt; &lt;/tbody&gt;

        &amp;lt;/table&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&lt;/pre&gt;&lt;div&gt;&lt;br&gt;lalu saya punya modal tambah data seperti ini:&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;pre&gt;&amp;lt;div class=&quot;modal fade&quot; id=&quot;modaltambahUser&quot; data-bs-backdrop=&quot;static&quot; data-bs-keyboard=&quot;false&quot; tabindex=&quot;-1&quot; aria-labelledby=&quot;modaltambahUserLabel&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;user/tambah.php&quot; method=&quot;post&quot;&amp;gt;
                &amp;lt;div class=&quot;modal-header bg-success text-white&quot;&amp;gt;
                    &amp;lt;h5 class=&quot;modal-title&quot; id=&quot;modaltambahUserLabelHeader&quot;&amp;gt;Tambah User&amp;lt;/h5&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;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;idUser&quot; class=&quot;form-label fw-bold&quot; hidden&amp;gt;ID User&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;idUser&quot; name=&quot;idUser&quot; aria-describedby=&quot;idUser&quot; hidden&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;userName&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Username&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;userName&quot; name=&quot;userName&quot; aria-describedby=&quot;userName&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;password&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Password&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;password&quot; class=&quot;form-control form-control-sm&quot; id=&quot;password&quot; name=&quot;password&quot; aria-describedby=&quot;password&quot; required autocomplete=&quot;off&quot;&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;idUker&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Unit Kerja&amp;lt;/label&amp;gt;
                        &amp;lt;select id=&quot;idUker&quot; name=&quot;idUker&quot; class=&quot;form-select form-select-sm&quot; aria-label=&quot;Default select example&quot;&amp;gt;
                            &amp;lt;option disabled selected&amp;gt; --Pilih Unit Kerja-- &amp;lt;/option&amp;gt;
                            &amp;lt;?php
                            $pilihUker = mysqli_query($koneksi, &quot;SELECT * FROM uker ORDER BY idUker ASC&quot;);
                            while ($row = mysqli_fetch_array($pilihUker)) {
                            ?&amp;gt;
                                &amp;lt;option value=&quot;&amp;lt;?php echo $row[&#039;idUker&#039;] ?&amp;gt;&quot;&amp;gt;&amp;lt;?php echo $row[&#039;namaUker&#039;] ?&amp;gt;&amp;lt;/option&amp;gt;
                            &amp;lt;?php
                            };
                            ?&amp;gt;
                        &amp;lt;/select&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;levelUser&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Level User&amp;lt;/label&amp;gt;
                        &amp;lt;select id=&quot;levelUser&quot; name=&quot;levelUser&quot; class=&quot;form-select form-select-sm&quot; aria-label=&quot;Default select example&quot;&amp;gt;
                            &amp;lt;option disabled selected&amp;gt; --Pilih Level User-- &amp;lt;/option&amp;gt;
                            &amp;lt;option value=&quot;1&quot;&amp;gt;Level 1&amp;lt;/option&amp;gt;
                            &amp;lt;option value=&quot;99&quot;&amp;gt;Level 99&amp;lt;/option&amp;gt;
                        &amp;lt;/select&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;modal-footer&quot;&amp;gt;
                    &amp;lt;button type=&quot;submit&quot; type=&quot;button&quot; class=&quot;btn btn-primary btn-success btn-sm&quot; id=&quot;simpanUser&quot; name=&quot;simpanUser&quot;&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;Batal&amp;lt;/button&amp;gt;
                    &amp;lt;button type=&quot;button&quot; class=&quot;btn btn-secondary btn-danger btn-sm&quot; data-bs-dismiss=&quot;modal&quot;&amp;gt;Close&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;&lt;/pre&gt;&lt;div&gt;&lt;br&gt;dan modal ubah data seperti ini:&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;pre&gt;&amp;lt;div class=&quot;modal fade&quot; id=&quot;modalubahUser&quot; data-bs-backdrop=&quot;static&quot; data-bs-keyboard=&quot;false&quot; tabindex=&quot;-1&quot; aria-labelledby=&quot;modalubahUserLabel&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;&amp;gt;
                &amp;lt;div class=&quot;modal-header bg-warning&quot;&amp;gt;
                    &amp;lt;h5 class=&quot;modal-title&quot; id=&quot;modalubahUserLabelHeader&quot;&amp;gt;Ubah User&amp;lt;/h5&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;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;ubahidUser&quot; class=&quot;form-label fw-bold&quot; hidden&amp;gt;ID User&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;ubahidUser&quot; name=&quot;ubahidUser&quot; aria-describedby=&quot;ubahidUser&quot; hidden&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;ubahuserName&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Username&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; id=&quot;ubahuserName&quot; name=&quot;ubahuserName&quot; aria-describedby=&quot;ubahuserName&quot; required&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;ubahpassword&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Password&amp;lt;/label&amp;gt;
                        &amp;lt;input type=&quot;ubahpassword&quot; class=&quot;form-control form-control-sm&quot; id=&quot;ubahpassword&quot; name=&quot;ubahpassword&quot; aria-describedby=&quot;ubahpassword&quot; required autocomplete=&quot;off&quot;&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;ubahidUker&quot; class=&quot;form-label fw-bold&quot;&amp;gt;ubahidUker&amp;lt;/label&amp;gt;
                        &amp;lt;select id=&quot;ubahidUker&quot; name=&quot;ubahidUker&quot; class=&quot;form-select form-select-sm&quot; aria-label=&quot;Default select example&quot;&amp;gt;
                            &amp;lt;?php
                            $pilihUker = mysqli_query($koneksi, &quot;SELECT * FROM uker ORDER BY idUker ASC&quot;);
                            while ($row = mysqli_fetch_array($pilihUker)) {
                            ?&amp;gt;
                                &amp;lt;option value=&quot;&amp;lt;?php echo $row[&#039;idUker&#039;] ?&amp;gt;&quot;&amp;gt;&amp;lt;?php echo $row[&#039;namaUker&#039;] ?&amp;gt;&amp;lt;/option&amp;gt;
                            &amp;lt;?php
                            };
                            ?&amp;gt;
                        &amp;lt;/select&amp;gt;
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div class=&quot;mb-3&quot;&amp;gt;
                        &amp;lt;label for=&quot;ubahlevelUser&quot; class=&quot;form-label fw-bold&quot;&amp;gt;Level User&amp;lt;/label&amp;gt;
                        &amp;lt;select id=&quot;ubahlevelUser&quot; name=&quot;ubahlevelUser&quot; class=&quot;form-select form-select-sm&quot; aria-label=&quot;Default select example&quot;&amp;gt;
                            &amp;lt;option value=&quot;1&quot;&amp;gt;Level 1&amp;lt;/option&amp;gt;
                            &amp;lt;option value=&quot;99&quot;&amp;gt;Level 99&amp;lt;/option&amp;gt;
                        &amp;lt;/select&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
                &amp;lt;div class=&quot;modal-footer&quot;&amp;gt;
                    &amp;lt;button type=&quot;submit&quot; type=&quot;button&quot; class=&quot;btn btn-primary btn-success btn-sm&quot; id=&quot;updateUser&quot; name=&quot;updateUser&quot;&amp;gt;Simpan&amp;lt;/button&amp;gt;
                    &amp;lt;button type=&quot;button&quot; class=&quot;btn btn-secondary btn-danger btn-sm&quot; data-bs-dismiss=&quot;modal&quot;&amp;gt;Close&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;&lt;/pre&gt;&lt;div&gt;&lt;br&gt;fungsi yang saya pakai untuk menyimpan data kurang lbih seperti ini:&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;pre&gt;&amp;lt;script&amp;gt;
    &lt;em&gt;function&lt;/em&gt; hapusUser(&lt;em&gt;hapusid&lt;/em&gt;) {
        Swal.fire({
            title: &#039;Yakin?&#039;,
            text: &quot;Anda Akan Menghapus Data Ini!&quot;,
            icon: &#039;question&#039;,
            showCancelButton: true,
            confirmButtonColor: &#039;#3085d6&#039;,
            cancelButtonColor: &#039;#d33&#039;,
            confirmButtonText: &#039;Ya, Hapus!&#039;
        }).then((&lt;em&gt;result&lt;/em&gt;) &lt;em&gt;=&amp;gt;&lt;/em&gt; {
            if (result.isConfirmed) {
                $.ajax({
                    url: &#039;user/hapus.php&#039;,
                    type: &#039;post&#039;,
                    data: {
                        idUserHapus: hapusid
                    },
                    success: &lt;em&gt;function&lt;/em&gt;(&lt;em&gt;data&lt;/em&gt;, &lt;em&gt;status&lt;/em&gt;) {
                        Swal.fire(
                            &#039;Terhapus!&#039;,
                            &#039;Data Sudah Dihapus&#039;,
                            &#039;success&#039;
                        ).then(&lt;em&gt;function&lt;/em&gt;() {
                            location.reload()
                        });
                    }
                });
            }
        })

    }

    &lt;em&gt;function&lt;/em&gt; getDetailUser(&lt;em&gt;ubahid&lt;/em&gt;) {
        $(&#039;#ubahidUser&#039;).val(ubahid);
        $.ajax({
            url: &#039;user/ubah.php&#039;,
            type: &#039;post&#039;,
            data: {
                ubahid: ubahid
            },
            success: &lt;em&gt;function&lt;/em&gt;(&lt;em&gt;data&lt;/em&gt;, &lt;em&gt;status&lt;/em&gt;) {
                &lt;em&gt;var&lt;/em&gt; userId = JSON.parse(data);
                $(&#039;#ubahuserName&#039;).val(userId.userName);
                $(&#039;#ubahpassword&#039;).val(userId.password);
                $(&#039;#ubahidUker&#039;).val(userId.idUker);
                $(&#039;#ubahlevelUser&#039;).val(userId.levelUser);
            },
        });
        $(&#039;#modalubahUser&#039;).modal(&#039;show&#039;);
    }

    $(document).on(&#039;click&#039;, &#039;#updateUser&#039;, &lt;em&gt;function&lt;/em&gt;() {
        &lt;em&gt;var&lt;/em&gt; idUser = $(&#039;#ubahidUser&#039;).val();
        &lt;em&gt;var&lt;/em&gt; userName = $(&#039;#ubahuserName&#039;).val();
        &lt;em&gt;var&lt;/em&gt; password = $(&#039;#ubahpassword&#039;).val();
        &lt;em&gt;var&lt;/em&gt; idUker = $(&#039;#ubahidUker&#039;).val();
        &lt;em&gt;var&lt;/em&gt; levelUser = $(&#039;#ubahlevelUser&#039;).val();
        $.ajax({
            url: &#039;user/update.php&#039;,
            type: &#039;post&#039;,
            data: {
                idUserUpdate: idUser,
                userNameUpdate: userName,
                passwordUpdate: password,
                idUkerUpdate: idUker,
                levelUserUpdate: levelUser
            },
            success: &lt;em&gt;function&lt;/em&gt;(&lt;em&gt;data&lt;/em&gt;, &lt;em&gt;status&lt;/em&gt;) {
                Swal.fire(
                    &#039;Berhasil!&#039;,
                    &#039;Data Sudah Diupdate&#039;,
                    &#039;success&#039;
                ).then(&lt;em&gt;function&lt;/em&gt;() {
                    window.location.reload();
                })
            },
        });
        $(&#039;#modalubahUser&#039;).modal(&#039;hide&#039;);
    });

    $(document).ready(&lt;em&gt;function&lt;/em&gt;() {
        $(&#039;#example&#039;).DataTable();
    });
&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;div&gt;&lt;br&gt;masalah terjadi ketika saya mau ubah data melalui modal ubah.saat saya menyimpan data di form ubah dengan menekan tombol #updateUser,data di database berubah sesuai nilai di form.tapi data yang tampil di tabel,tidak langsung berubah.saat saya refresh halaman,notif resubmission terus muncul.masalah ini terjadi di page yang ada form control tipe select option,sementara di halaman yang tidak ada form control select option,tidak ada masalah.mohon bantuannya.&lt;/div&gt;
avatar ruben46
@ruben46

20 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

Tanggapan

Aku tidak tau Swal.fire fungsinya untuk apa. Tapi yg pasti.. window.location.reload() ini memang beneran tidak pernah tereksekusi, mungkin swal.fire pun juga sama.

Seperti jawaban ku sebelumnya. Kamu perlu menambhain preventDefault. Karena #updateUser mu itu berupa button type submit

Yg mana sekali diklik akan langsung berubah halaman nya sesusi parameter action di tag form

Jadinya kamu mengira location.reload yg membuat refresh halaman tapi sebenarnya itu baris gak nyampe kesitu karena ke reload duluan

swal.fire itu script untuk memanggil pop up sweet alert kak.terima kasih kak @GrennKren.saran prevent default nya berhasil.problem solved.terima kasih banyak.

Login untuk ikut Jawaban