The messager works in async mode, so you can't block it like the native 'confirm' function. Here is the possible way to send your array data with confirmation.
function confirmData(data){
// filter the data to send
data = data.filter(item => item == 1);
// the data item index
var index = 0;
var el = $('<div></div>').on('confirm', function(){
if (index < data.length){
$.messager.confirm({
title: 'Test',
msg: 'Are you sure to send data?',
fn: function(r){
console.log('send '+index);
index++;
el.triggerHandler('confirm');
}
})
}
})
el.triggerHandler('confirm');
}
var sendData = [1,2,1,3];
confirmData(sendData);