XMLHTTPREQUEST chrome extension not working

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.

What does it do :

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.

But its completely not working!


I tried to pack the extension then run it by drag and drop, it doesn’t
launch php script.

I tried to uninstall chrome, restart and then install it again but
with no luck.

I have also allowed –allow-file-access-from-files


I am receiving the following error in debug mode:

extensions::sendRequest:41: Uncaught TypeError: Cannot read property ‘callback’ of undefined{TypeError: Cannot read property ‘callback’ of


  "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": [

  "commands": {
           "toggle-feature": {
            "suggested_key": {
              "default": "Ctrl+Shift+1",
              "windows": "Ctrl+Shift+2"

            "description": "Extract now"
        } ,
"web_accessible_resources": ["content_script.js"]



chrome.commands.onCommand.addListener(function(command) {
 if (command === "toggle-feature") { 
 chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
     for(var i = 0; i<tabs.length;i++) {
           chrome.tabs.executeScript(tabs[i].id, {"file": "content_script.js"});

  function(message, sender, sendResponse) {

    var xhttp = new XMLHttpRequest();
    xhttp.open("POST", "http://localhost/test/test.php");



var url = 'this is just test' ;
chrome.runtime.sendMessage({ 'url' : url });


echo "hello";

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.