Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. debugging chrome extension
  2. ...
  3.  
  4.   function init() {
  5.       getdata();
  6.   }
  7.  
  8.   var txt;
  9.   function getdata() {
  10.       var xhr = new XMLHttpRequest();
  11.       xhr.open('GET',myurl, true);
  12.       xhr.setRequestHeader('Cache-Control', 'no-cache');
  13.       xhr.setRequestHeader('Pragma', 'no-cache');
  14.       xhr.onreadystatechange = function() {
  15.           if (xhr.readyState == 4) if (xhr.responseText) {
  16.               txt = xhr.responseText;
  17.           }
  18.       }
  19.  
  20.       xhr.send();
  21.       console.log(txt);
  22.   }
  23.  
  24. ...
  25.  
  26. <body onload="init();">
  27.  
  28. ...