Skip to content

Instantly share code, notes, and snippets.

@lili668668
Created Jan 18, 2019
Embed
What would you like to do?
<!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