导航栏: 首页 评论列表

req 请求函数2

默认分类 2022/06/23 06:50

如下:

var list = [

"http://top.zhan.com/mob/ielts/read/review-202-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-204-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-206-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-208-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-210-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-212-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-201-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-203-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-205-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-207-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-209-1-1.html", 
"http://top.zhan.com/mob/ielts/read/review-211-1-1.html",
]

function createXHR(url) {
  let xhr = new XMLHttpRequest()
  xhr.open('GET', url, true)
  xhr.setRequestHeader('Accept-Timezone', 'UTC+8')
  xhr.onreadystatechange = () => {
    if (xhr.readyState !== 4) return ''
    window.setTimeout(run, 30)
  }
  xhr.send()
}

function run () {
  var url = list.pop()
  if (url) createXHR(url)
}


>> 留言评论