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 3307020
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:21:26+00:00 2026-05-17T21:21:26+00:00

I have a javascript script in a chrome extension i’m building. It is content

  • 0

I have a javascript script in a chrome extension i’m building. It is content script.

The script is using mediawiki api:

function wikifind(str)
{
    var req = new XMLHttpRequest();
    url = "http://en.wikipedia.org/w/api.php?action=query&format=xml&titles="+str;
    req.open("GET", url, true);
    req.send;
}    

I have two questions.

First There is the event of the response. not sure where I’m supposed to put it.

req.onreadystatechange=function()
{
    if (req.readyState==4 && req.status==200)
    {
        document.write(req.responseXML);
    }
}

Somewhere after the function that sends the request, inside it or otherwise?

Second more important question/problem is that when I try to access the response I get null value.

I tried to switch the format to JSON as was said in a similar question, but that didn’t work. Also tried synchronous requests, but still getting null value.

Any ideas? Does this have anything to do with security limitations of extensions, or just problems with my code?

  • 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-17T21:21:27+00:00Added an answer on May 17, 2026 at 9:21 pm

    This looks like a same-origin problem to me. As per the documentation, cross-domain XHR is not supported from content scripts. Users are recommended to create a background page, declare cross-origin permissions to the site in question (in this case http://en.wikipedia.org) in the manifest and then communicate between the content script and the background page using message passing.

    An example of this technique (with source code) is available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: <script type=text/javascript> function SubmitForm() { form1.submit(); } function ShowResponse()
I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:
I have following page <html> <head> <script type=text/javascript src=e01.js></script> </head> <body> <script type=text/javascript> var
How do I pass have a Javascript script request a PHP page and pass
Say I have several JavaScript includes in a page: <script type=text/javascript src=/js/script0.js></script> <script type=text/javascript
I have minified my javascript and my css. Now, Which is better? <script type=text/javascript>
I have the following very simple Javascript-compatible regular expression: <script type=text/javascript id=(.+) src=([^]+)> I
Duplicate of: Use javascript to inject script references as needed? Javascript doesn't have any
I have this java code: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> google.load(jquery, 1.2.6); $(a#more).click(function() { $(#info_box).show(blind,
How have you guys handled working with jQuery includes <script type=text/javascript src=jquery.js></script> in Asp.Net

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.