I have a form where a subscriber can select the newsletters they want to recieve and then an AJAX form will send the results to Exact Target and add the subscriber to every list the subscriber want to be added too.
I have a PHP foreach loop setup to handle this.
<?php foreach ($listNumbers as $item): ?>
var xmlData = 'Ths is the ET API call';
$.post('ET url for API call'+xmlData);
<?php endforeach; ?>
After the loop(s) run the user is sent to a thank you page like this.
$(document).ready(function() {
location.href = "thank you url";
});
Everything works.. for the most part. I'm using document ready because I'm wanting to give the loop enough time to submit the API call. Is there a way to detect when the $.post function(s) are complete? If it is sucessfull? and then send the user to thank you page?
I'm finding that the location href is sending some users to the thank you page before the code has a chance to run.
Thanks, Michael