I want to pass imageArray[]
along with a variable trackNo
. The imageArray[]
I can pass it fine with no problem. I'm just uncertain on how to append/include other variables to the FormData()
Online I only see examples of people passing only a file array to a php file and never with other information.
$('#ad_post_btn').click(function () {
ad_errmsg = "";
imageList = myImageList(); //my array of images imageList[]
console.log(imageList); //display files in imageList[]
var trackNo = Math.round(Math.random() * (100000 - 1) + 1); // random number
console.log(trackNo); // shows the random generated number
var data = new FormData();
var dataString = 'trackno=' + trackNo; //the variable a want to pass along with the array
for (var i = 0; i < imageList.length; i++) {
data.append('images[]', imageList[i]); //where I store my image files, work fine
}
$.ajax({
url: 'uploadimage.php',
type: 'post',
data: data,
contentType: false,
processData: false,
success: function (data) {
console.log(data);
}
});
I've tried
data: data,dataString ,
Thank you for your time