Yair Abraham
asked on
how i use a async function
Hello this is my cod for a test page
1) I am expected that alert 2 will come before the alert 1 because the async -
2) on IE11 async function inLoop() get error
I have long script that give a not responding for some time i thought to use async that the problematic function will run on the background - this is possible?
<script language="javascript" type="text/javascript">
$(document).ready(function() {
inLoop()
/*var suport_fileReader;
try { suport_fileReader = (window.FileReader) ? true : false }
catch(e) {}
document.getElementById("windowFileReader").innerHTML = suport_fileReader;
document.getElementById("modernizrDragnDrop").innerHTML = Modernizr.draganddrop; */
secFunc()
});
async function inLoop() {
var startTime = Date.now();
while ((Date.now() - startTime) < 3000) {
console.log("In Loop ", (Date.now() - startTime) )
}
alert(1)
}
function secFunc(){
alert(2)
}
</script>
<body>
<h1>Tests</h1>
1) I am expected that alert 2 will come before the alert 1 because the async -
2) on IE11 async function inLoop() get error
I have long script that give a not responding for some time i thought to use async that the problematic function will run on the background - this is possible?
Please take a look at
https://caniuse.com/#search=async
Specifically the async functions section.
Async for functions is not supported on IE11
https://caniuse.com/#search=async
Specifically the async functions section.
Async for functions is not supported on IE11
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Do you want really to loop? if not what not just using `setTimeout()`?