How jquery converts multiple identical forms into json arrays.

for example, there is a requirement that a person can add multiple internships, and I can click a button on the page to add form, for multiple internships. The content of this form is the same, and so is class. The json format of each form is
{Id: "1", name: "xsx", content: "this is an example"}, which I have obtained.
the format requirements for multiple identical forms (with the same input name value) are
[{Id: "1", name: "xsx", content: "this is an example"}, {Id: "1", name: "xsx", content: "this is an example"}, {Id: "1", name: "xsx", content: "this is an example"},
the problem now is that I use traversal to push each form into an array, but what comes out is {Id: ["1", "2", "3"], name: ["xsx", "sdw", "www"], content: ["this is an example1", "this is an example2", "this is an example3"]}, which is completely wrong.

:

ask for help!

Mar.03,2021

var data = $('.bbbb'). SerializeObject ()) the values of all forms should be put together here, and there is no grouping storage for different forms.
it is recommended that https://github.com/marioizqui. should be converted to json,

.

pseudo code is something like this

var datas , data;
$('.bbbb').each(function(){
    data = serializeJSON($(this));
    datas.push(data);
})
//datas data; 

JSON.stringify No need


$.fn.serializeObject = function(){
  var result = []
  $(this).each(function(){
    var obj = {}
    $($(this).serializeArray()).each(function(){
      obj[this.name]=this.value;
    })
    result.push(obj);
  })
  return result;
}

Thank you, it has been solved. Here's my solution:
when a form is serialized:

:

where $(".xxx _ form") is the class, of the form (because the id value is unique, so use the class selector here), the key is to traverse the content

json.push ($(this). SerializeObject ()); this $(this) is the key to solving this problem and what I overlooked.

The json variable returned by

is exactly what I want.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8e1fb-46f92.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8e1fb-46f92.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?