You are viewing a single comment's thread from:

RE: JavaScript开发笔记

in #starnote2 days ago
function get(url, callback) {
  var oReq = new XMLHttpRequest()
  // 当请求加载成功之后要调用指定的函数
  oReq.onload = function () {
    // 我现在需要得到这里的 oReq.responseText
    callback(oReq.responseText)
  }
  oReq.open("get", url, true)
  oReq.send()
}

get('data.json', function (data) {
  console.log(data)
})