Skip to content

Instantly share code, notes, and snippets.

@lili668668
Created January 18, 2019 15:14
Show Gist options
  • Save lili668668/411362f7bb57af90bb15c64d92ee3894 to your computer and use it in GitHub Desktop.
Save lili668668/411362f7bb57af90bb15c64d92ee3894 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Bridgewell</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<script>
(function (i, max_i) {
const callAjax = (cnt) => {
return new Promise((resolve) => {
$.ajax({
url: 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.' + cnt + '/jquery.min.js',
success: resolve
})
})
}
const callAjaxAgain = (cnt) => {
return callAjax(cnt)
.then(() => {
console.log(cnt)
cnt++
if (cnt < max_i) callAjaxAgain(cnt)
})
}
callAjaxAgain(i)
})(1, 5);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment