0

I want to add another item to formData.serializeArray() and send formData with ajax to laravel controller. Here is what I have tried:

    var formData = $('#form').serializeArray();

formData.push({"name":"inputValue", "value": '1' });

$.ajax({

   url: 'url',

   type:"POST",

   data:  formData,

   dataType : 'json',

   cache: false,

   success: function (data) {

   }
 })

In jquery, data pushed correctly. but, it doesn't send pushed data with ajax . it just send form data without new item.

Why it doesn't send pushed data with ajax?

Haniye Shadman
  • 357
  • 1
  • 6
  • 19

1 Answers1

0

Please try this:

formData.push({"name":"inputValue", "value": '1' });

This should work can you try once again by console.log(formData);

Sarvil Ajwaliya
  • 233
  • 1
  • 8