Article From:https://segmentfault.com/q/1010000010893534
Question:

Interface

Click the button to generate a table. The first cell in the form is the selecte drop-down box, and each additional line of TD is selected.

$(‘form’).serialize()The serialization is the content of all form

Now I want to submit each table with a small array and put it in a large array.

Answer 0:

The landlord first explains the code above
1.When you submitted the success of Ajax, what is the purpose of assembling the array in the success called?
2.arr When was the array defined and what was in it?
3.What data do you want POST?
4.data If the array is assembled, what do you use to do
5.successThe result returned doesn’t mean anything to you. Why is it not used in the code?

===============================

success It will be called after submission. You can not do the data assembly to be submitted here.

I don’t know what your background design is like. If it were me, I would submit the whole array in the form of json, one time, and do the background processing.

$.ajax({
    type:'post',
    datatype: 'json',
    url:'yourposturl',
    data: json.stringify(configContentList) ,//This is where the data is submitted.Success: function (result) {Console.log ('successful submission!Dosomething (result)},Error: function (ERR) {Console.log ('where did it go wrong!Console.log (ERR)}})

Answer 1:

var saveList = [];

$(‘.J_submit’).click(function() {

var list = $('.table-list');

for (var i = 0; i < list.length; i++) {
  saveList.push([]); //Add a set of dataVar params = $(list[i]).SerializeArray ();SaveList[i].push (params); / / add elements to the corresponding array.}ConsOle.info (saveList);//ajax

});

Leave a Reply

Your email address will not be published. Required fields are marked *