“formulario AJAX Enviar” Código de respuesta

JQuery AJAX Formulario Enviar

// 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

Enviar formulario usando 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

envío del formulario jQuery AJAX

$(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

formulario jQuery Enviar 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 Enviar datos de formulario

<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

formulario AJAX Enviar

Ajax jquery form submit
Good Grouse

Respuestas similares a “formulario AJAX Enviar”

Preguntas similares a “formulario AJAX Enviar”

Más respuestas relacionadas con “formulario AJAX Enviar” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código