How to send data from two forms?

Good day!
The situation is this, the site has one big form with the goods, on button click POPs up a popup in which you enter the field name, phone, address. How to send data at the same time these two forms to the server?
Now I use ajax for great shape.
All the data should come in 1 file .....
var formData = new FormData($('.menuOrderForm')[0]); //Get data from form
$.ajax({
 type: "POST",
 url: "/testorder.php",
 cache: false,
 contentType: false,
 processData: false,
 data: formData,
 beforeSend: function(){
 // $("#large-img").show();
},

 success: function(data) {
alert("da");
console.log(data);
},
 error: function(data){
alert("no");
console.log(data);
}
 });return false;
July 12th 19 at 17:08
4 answers
July 12th 19 at 17:10
a pop-up window must be in a different form? why not make it a part first?
July 12th 19 at 17:12
add data to formData the data from the 2nd form using formData.append()
And the data from the second form too formData to do?) - antonette_Bro commented on July 12th 19 at 17:15
: if there's not a lot of fields, then consider the value and append to the formData first, so problems will be less - trisha_Kovacek commented on July 12th 19 at 17:18
July 12th 19 at 17:14
On submit of the first form to hang up the handler
$('form.#someID').on('click', function(event) {
event.preventDefault();
...

then wait to fill the second form and to send data to the server using the same Ajax ...
July 12th 19 at 17:16
Why not gather all these data in array and send just an array in your handler. And inside the php file, parse it and send it where you want?
Write the data pop-up when PC with one variable from form to another and send one request.

var FirstForm = new FormData($('.menuOrderForm')[0]),
 SecondForm = $('#FormData').val(),
 data = [ FirstForm, SecondForm];

// Then using AJAX, send the data where it is necessary


if(isset($_POST['data'])){
 $dataArray = $_POST['data'];
 $data1 = $dataArray[0];
 $data2 = $dataArray[1]; 

// Manipulation you need
}

Find more questions by tags HTMLjQueryJavaScript