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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:10:55+00:00 2026-05-20T15:10:55+00:00

I am making a html page intended to be run locally on a PC,

  • 0

I am making a html page intended to be run locally on a PC, preferably without a local server runing (file://). I am also using jQuery to make manipulation/AJAX a little easier.

I am trying to load 2 results from the twitter API, but I get an error. The code is as follows:

$.getJSON("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=someuser&count=9", {},
    function (data) {
        $.each(data.items, doSomething1);
    });
$.getJSON("http://search.twitter.com/search.json?q=somequery&result_type=recent&count=9", {},
    function (data) {
        $.each(data.items, doSomething2);
    });

I also tried the following code, but it didn’t change the outcome.

$.getJSON("http://api.twitter.com/1/statuses/user_timeline.json",
    {
        count:          "9",
        screen_name:    "someuser"
    },
    function(data) {
        $.each(data.items, updateAWTweets);
    });
$.getJSON("http://search.twitter.com/search.json",
    {
        q:              "somequery",
        result_type:    "recent",
        count:          "9"
    },
    function(data) {
        $.each(data.items, updateHashTagTweets);
    });

I get the following error in chrome (on a localhost server):

XMLHttpRequest cannot load http://search.twitter.com/search.json?q=somequery&result_type=recent&count=9. Origin http://localhost:62153 is not allowed by Access-Control-Allow-Origin.

or (with a file:// link)

XMLHttpRequest cannot load http://api.twitter.com/1/statuses/user_timeline.json?screen_name=someuser&count=9. Origin null is not allowed by Access-Control-Allow-Origin.

Does anyone know how I can fix this?

  • 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-20T15:10:56+00:00Added an answer on May 20, 2026 at 3:10 pm

    You’re running into the same-origin policy restriction – your script can’t access any other domain apart from the one it was loaded from.

    1. You could give JSONP a try – that’s one common solution to getting data across domains:

      • http://www.chazzuka.com/blog/?p=221
      • http://jquery-howto.blogspot.com/2009/04/twitter-jsonjsonp-api-url.html

      Your code would look something like this (note the addition of callback=? to the URL):

      $.getJSON("http://search.twitter.com/search.json?q=somequery&result_type=recent&count=9&callback=?", 
                {},
                function (data) {
                        $.each(data.items, doSomething2);  
           });
      
    2. Another option is to setup a proxy – you can use Apache httpd as a proxy/reverse proxy to get around this restriction.

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

Sidebar

Related Questions

I am making an add-on for firefox and it loads a html page using
I am making a html page in which i am using table for the
im having a setback, im making an Html page with javascript, and im using
I am making a small HTML page editor. The editor loads a file into
Is there any way to load a local file using an html document that
I've got an html page from where Im making this call periodically: function logon(id)
I'm making my own website using html and php, and a database using mysql
I am making my first program with beautifulsoup and my html file has code
I am making a HTML page, with JavaScript. In the HTML is the first
I am trying to work on getting better at making HTML forms using PHP

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.