“Formulir JQuery Ajax Kirim” Kode Jawaban

Formulir JQuery Ajax Kirim

// jQuery ajax form submit example, runs when form is submitted
$("#myFormID").submit(function(e) {
    e.preventDefault(); // prevent actual form submit
    var form = $(this);
    var url = form.attr('action'); //get submit url [replace url here if desired]
    $.ajax({
         type: "POST",
         url: url,
         data: form.serialize(), // serializes form input
         success: function(data){
             console.log(data);
         }
    });
});
Grepper

Kirim formulir menggunakan Ajax

// add jquery
// <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
$(document).ready(function() {
  $("#form").on('submit', (function(e) {
    e.preventDefault();
    $.ajax({
      url: $(this).attr('action'),
      type: "POST",
      data: new FormData(this),
      contentType: false,
      cache: false,
      processData: false,
      success: function(response) {
        $("#form").trigger("reset"); // to reset form input fields
      },
      error: function(e) {
        console.log(e);
      }
    });
  }));
});
Terrible Tern

Pengajuan formulir Ajax JQuery

$(function() {
  $('form.my_form').submit(function(event) {
    event.preventDefault(); // Prevent the form from submitting via the browser
    var form = $(this);
    $.ajax({
      type: form.attr('method'),
      url: form.attr('action'),
      data: form.serialize()
    }).done(function(data) {
      // Optionally alert the user of success here...
    }).fail(function(data) {
      // Optionally alert the user of an error here...
    });
  });
});
Vyas

Formulir jQuery Kirim Ajax

    $(document).on('click', '#save_province', function () {
        var a = $("#province").val(), b = $("#district").val(), c = getParameterByName('supplier_id');
        $.ajax({
            url: "postavshik_save.php",
            type: "POST",
            data: {
                province: a,
                district: b,
                supplier_id: c,
            },
            beforeSend: function () {
                $("#province").attr("disabled", !0), $("#district").attr("disabled", !0);
            },
            success: function (a) {
                alert("Post so`rov yuborildi javob olindi");
            }
        });
    });
Shadow

AJAX mengirimkan data formulir

<form id="contactForm1" action="/your_url" method="post">
    <!-- Form input fields here (do not forget your name attributes). -->
</form>

<script type="text/javascript">
    var frm = $('#contactForm1');

    frm.submit(function (e) {

        e.preventDefault();

        $.ajax({
            type: frm.attr('method'),
            url: frm.attr('action'),
            data: frm.serialize(),
            success: function (data) {
                console.log('Submission was successful.');
                console.log(data);
            },
            error: function (data) {
                console.log('An error occurred.');
                console.log(data);
            },
        });
    });
</script>
Uninterested Unicorn

JQuery Ajax Form Form Kirimkan contoh

$.ajax({
			    type: "POST",
			    url: "upload.php",
			    data: { name:name, mobile:mobile, address:address, city:city },		    
			    dataType: "json",
			    success: function(result){
			        			    }
			});
Black Bat

Jawaban yang mirip dengan “Formulir JQuery Ajax Kirim”

Pertanyaan yang mirip dengan “Formulir JQuery Ajax Kirim”

Lebih banyak jawaban terkait untuk “Formulir JQuery Ajax Kirim” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya