mardi 13 juillet 2021

How to send multiple checkbox values through ajax

Hi I have multiple banks which user can select one or multiple.I am sending data through ajax but the problem is I get the first bank selected when I dd my request,I want the value of every bank which has been selected by the user. below is my code.I have different other components as well.

bankSelector.blade

                    <input
                        id="bank_"
                        name="banks"
                        class="form-check-input bank"
                        type="checkbox"
                        value=""
                        checked/>

ajax.js

              $('form').submit(function(e){
              e.preventDefault();
              let formData = new FormData(this)
            
        $.ajax({
          url: "/product/save",
          type: "POST",
          data: formData,
          contentType: false,
          processData: false,
          headers: {
            "X-CSRF-TOKEN": $('meta[name="_token"]').attr("content"),
          },
          success: function (data) {

            // show("#step8");
          },
          error: function () {

        },
    });
});



Aucun commentaire:

Enregistrer un commentaire