Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4337540
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:57:30+00:00 2026-05-21T10:57:30+00:00

I can’t get this to work – I’m following the actual docs, as well

  • 0

I can’t get this to work – I’m following the actual docs, as well as this example:

http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/howto/contentscript_xhr/

I’m simply trying to GET json data, formatted to the browser screen like so: {“name”:”value”}, from a URL, but get a “null” value returned when I alert.

My manifest.json:

{
  "name": "Chrome Extension",
  "version": "1.0",
  "description": "Does a GET request cross-domain.",
  "background_page": "plugin.html",
  "permissions": [
    "tabs",
    "http://*"
  ],
  "browser_action": {
    "default_title": "",
    "default_icon": "icon.ico"
  }
}

My plugin.html:

<html>
<head>
    <script>
        function fetchData(callback) {
            var req = new XMLHttpRequest();
            req.onreadystatechange = function (data) {
                if (req.readyState == 4) {
                    if (req.status == 200) {
                        callback(req.responseText);
                    } else {
                        callback(null);
                    }
                }
            };
            var url = 'http://foo/bar.php';
            req.open('GET', url, true);
            req.send();
        };

        function onRequest(request, sender, callback) {
            if (request.action == 'fetchData') {
                fetchData(callback);
            }
        };

        chrome.extension.onRequest.addListener(onRequest);

        chrome.browserAction.onClicked.addListener(function(tab) {
            chrome.tabs.create({url: 'index.html'});
        });
    </script>
</head>
</html>

My index.html:

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    </head>
        <body>
             <script type="text/javascript">
                  function onReturn(data) {
                   alert('Data ' + data);
                };
                  chrome.extension.sendRequest({'action' : 'fetchData'}, onReturn);
              </script>
        </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:57:31+00:00Added an answer on May 21, 2026 at 10:57 am

    Duh. chrome extension – ip domain permissions

    http://*/*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone give me an example of how to return the following json simply
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can't work out a way to make an array of buttons in android. This
Can anyone help me trying to find out why this doesn't work. The brushes
Can't get this working.. What am I missing here.. NodeJS, Mongoskin.. I cannot get
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Can anyone explain to me why this program: for(float i = -1; i <

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.