title: How to use GM_xmlhttpRequest in Injected Code?
body: <p>I am writing a userscript that is injected into a webpage. The script reads some data from a web-server and I want to send messages to a listening application to react to the data. </p>
  
  <p>For now, all I'm doing is trying to send a string command to my listening application and see if I can read it. My code worked before it was injected, but afterwards I get an "undefined reference error". </p>
  
  <p>I suspect that this has something to do with this <a href="http://wiki.greasespot.net/0.7.20080121.0_compatibility" rel="noreferrer">"Greasemonkey access violation"</a>. However, I have been unable to find a solution that works. I'm developing in Chrome.</p>
  
  <p>Here is the section of code I can't get to work.</p>
  
  <pre><code>GM_xmlhttpRequest({
     method: "POST", 
     url: "http://localhost:7777", 
     data: "testing123",
     headers:  {
           "Content-Type": "application/x-www-form-urlencoded"
               },
     onload: function(response) 
     {
        if (response.responseText.indexOf("TEST") &gt; -1) 
        {
           console.log("Response confirmed..."); 
        }
     }
  }); 
  </code></pre>
  
  <p>I'm pretty new to scripting so maybe I'm missing something obvious. How do I get this to work in injected code?</p>