get_url.js 527 B

123456789101112131415
  1. const xhr = new XMLHttpRequest()
  2. xhr.open('GET', 'http://www.wechall.net/challenge/training/programming1/index.php?action=request')
  3. xhr.send(null)
  4. xhr.onreadystatechange = () => {
  5. const DONE = 4
  6. const OK = 200
  7. if (xhr.readyState === DONE) {
  8. if (xhr.status === OK) {
  9. const flag = xhr.responseText
  10. window.location.href = 'http://www.wechall.net/challenge/training/programming1/index.php?answer=' + flag
  11. } else {
  12. console.log('Error: '+ xhr.status)
  13. }
  14. }
  15. }