Although synchronous calls are not recommended, I am in a situation where I need to make one in ajax. The device I am working with requires user action before I can receive a response from it. My current ajax() code has been functioning well so far. However, I recently received a warning stating that "Synchronous XMLHttpRequest on the main thread is deprecated." The synchronous call returns the response from the device, which I then pass to my second call to generate the output:
<script>
var result = $.ajax({
url: 'url',
async: false,
type: "GET"
}).responseText;
$(document).ready(function() {
$.post("https://example.com/doit.php", {
response: result,account: <?php echo $account ?>,dn:<?php echo $dn ?>, mode:<?php echo $dest ?>},function(data){document.write(data);});
});
</script>
In order to continue using this setup, how can I modify my synchronous call?