I have tasks that I want to do synchronously; but I don't want to freeze the browser. There could be 1---N tasks.
Below is the synchronous version. It works as expected but freezes the browser.
How can I do this using jQuery deferred object to do these task in order but not lock browser.
NOTE: The server I am request to does NOT allow for 2 requests at once. They need to run one after the other once the request is finished in exact order.
<?php
for ($k = 0;$k<count($partial_transactions);$k++)
{
?>
$("#formCheckout_<?php echo $k; ?>").ajaxSubmit({
success:function(response)
{
var data = response.split("&");
var processed_data = [];
for(var i = 0; i < data.length; i++)
{
var m = data[i].split("=");
processed_data[m[0]] = m[1];
}
$("#please_wait").hide();
if (processed_data.CmdStatus != 'Approved')
{
var message = decodeURIComponent(message);
message = processed_data.TextResponse.replace(/\+/g, ' ');
toastr['error'](<?php echo json_encode(lang('sales_attempted_to_reverse_partial_transactions_failed_please_contact_support'));?>, <?php echo json_encode(lang('common_error')); ?>);
}
else
{
toastr['success'](<?php echo json_encode(lang('sales_partial_credit_card_transactions_voided')); ?>, <?php echo json_encode(lang('common_success')); ?>);
}
},
cache: true,
headers: false,
async: false
});
<?php
}
?>
i