title: HTML/Javascript- get data from raw pastebin
body: <p>I have a webpage in which I need to just get the raw data of a specified pastebin file, let's just say <a href="http://pastebin.com/qnNPx6G9" rel="nofollow noreferrer">http://pastebin.com/qnNPx6G9</a>, and store it as a variable. I've tried many, many, many variations on xml and ajax requests, but nothing works. Here's what I've tried. What am I doing wrong?</p>
  
  <p>I've tried with Ajax:</p>
  
  <pre><code>$.ajax({
  url: "http://pastebin.com/api/api_post.php",
  type: "GET",
  dataType: "x-www-form-urlencoded",
  data: {
      "api_dev_key": "mydevkey",
      "api_option": "paste",
      "api_paste_code": "blah blah"
  },
  success: function(res) {
      alert(JSON.stringify(res));
  },
  error: function(res) {
      alert(JSON.stringify(res));
  }
  });
  //this is in the form of create paste, because I was seeing if it would work where get did not- it didn't.
  </code></pre>
  
  <p>And with regular XMLHttpRequest:</p>
  
  <pre><code>var xhr = new XMLHttpRequest();
  xhr.open('POST'/*also tried GET*/, 'http://pastebin.com/raw/qnNPx6G9', true); //I've also tried /raw.php?i=qnNPx6G9
  xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
          alert(this.responseText);
        }
  };
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  xhr.send("api_option=trends&amp;api_dev_key=DEVKEY");
  //I tried trends because creating a paste and getting a paste didn't work.
  </code></pre>
  
  <p>Please help! I'm sorry if this is a stupid question or anything is unclear, I'm not that good at understanding APIs. Thanks!</p>
  
  <p>And no, I can't use PHP.</p>