title: XMLHTTPREQUEST chrome extension not working
body: <p>I am unable to send data from Chrome extension background script using XMLHTTPREQUEST , I have up and running wampserver, I also tried external links such as google.</p>
  
  <p><em>What does it do :</em></p>
  
  <blockquote>
    <p>User enters a permission defined tab, background script waits for hot
    key,when pressed a content_script is launched and generates a string,
    the string is sent back to the background script, then the background
    script should receive the string and send it to a php file, the php
    file should print hello, its made simple just to try see where is the
    problem, later php will have more code.</p>
    
    <p>But its completely not working!</p>
  </blockquote>
  
  <p><strong>UPDATE</strong></p>
  
  <blockquote>
    <p>I tried to pack the extension then run it by drag and drop, it doesn't
    launch php script.</p>
    
    <p>I tried to uninstall chrome, restart and then install it again but
    with no luck.</p>
    
    <p>I have also allowed <strong>--allow-file-access-from-files</strong></p>
  </blockquote>
  
  <p><strong>UPDATE 2</strong></p>
  
  <blockquote>
    <p>I am receiving the following error in debug mode:</p>
    
    <p><strong>extensions::sendRequest:41: Uncaught TypeError: Cannot read property 'callback' of undefined{TypeError: Cannot read property 'callback' of
    undefined</strong></p>
  </blockquote>
  
  <p><strong>Manifest.json</strong></p>
  
  <pre><code>{
  
    "manifest_version": 2,
    "name": "Extractor",
    "version": "1",
  
  
    "description": "Extract from 144",
    "icons": { "16": "logo16.png",
             "48": "logo48.png",
            "128": "logo128.png" },
  
  
          "page_action": {
            "default_icon": {                    
              "16": "logo16.png",           
              "48": "logo48.png",           
              "128": "logo128.png"            
            },
            "default_title": "Extractor"          
          },
  
    "background": {
  
      "scripts": ["background.js"],
      "persistent": true
    },
    "content_scripts": [
      {
        "matches" : ["https://www.msn.com/*"],
        "js" : ["content_script.js"]
      }
    ],
   "permissions": [
      "tabs",
      "https://www.msn.com/*",
      "activeTab",
       "http://localhost/*"
  
    ],
    "commands": {
             "toggle-feature": {
              "suggested_key": {
                "default": "Ctrl+Shift+1",
                "windows": "Ctrl+Shift+2"
              },
  
              "description": "Extract now"
            }
          } ,
  "web_accessible_resources": ["content_script.js"]
  
  }
  </code></pre>
  
  <p><strong>Background.js</strong></p>
  
  <pre><code>chrome.commands.onCommand.addListener(function(command) {
   if (command === "toggle-feature") { 
   chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
       for(var i = 0; i&lt;tabs.length;i++) {
             chrome.tabs.executeScript(tabs[i].id, {"file": "content_script.js"});
       }
     });
    }
  }); 
  
  chrome.runtime.onMessage.addListener(
    function(message, sender, sendResponse) {
  
      var xhttp = new XMLHttpRequest();
      xhttp.open("POST", "http://localhost/test/test.php");
      xhttp.send(message.url);
  
    });
  </code></pre>
  
  <p><strong>content_script.js</strong></p>
  
  <pre><code>var url = 'this is just test' ;
  chrome.runtime.sendMessage({ 'url' : url });
  </code></pre>
  
  <p><strong>test.php</strong></p>
  
  <pre><code>echo "hello";
  </code></pre>