I have two arrays. Both are getting from two different $.each() functions.
var firstArray = ['item1', 'item2', 'item3', 'item4']; // **Dynamic Values
var counter = 0;
$.each(function(i, v){
//some code....
secondArray[counter] = $(this).val();
//secondArray have these values ['value1', 'value2', 'value3', 'value4']
counter++;
if(counter >= 4){
$.ajax({
type: 'POST',
url: customURL,
data: ?????
});
}
});
Actually i want the result like the 'item1' will get the 'value1', 'item2' to 'value2' and so on. In past when i used static values like -
$.ajax({
type: 'POST',
url: customURL,
data: {
'item1' : value[0],
'item2' : value[1],
'item2' : value[2],
'item3' : value[3],
}
});
i got the results using these static values but how could i use dynamic values instead of 'item1', 'item2' and so on. Remember the 'firstArray' values are dynamic means they can be changed. I am using only jQuery and HTML.