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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:05:27+00:00 2026-05-19T14:05:27+00:00

I need to do a very simple cross domain api call, and for reasons

  • 0

I need to do a very simple cross domain api call, and for reasons of overhead/compatibility, dont want to use a fully-featured framework (such a jQuery), since this simple ajax request is pretty much all I need to do. I need to call do a GET request on http://bar.com from a page on http://foo.com. I cannot access the HTTP headers on foo.com however. I do not need to return data to the browser.

Currently doing the center code hereall results in (on Chrome):

XMLHttpRequest cannot load http://bar.com/api?=x. 
Origin http://foo.com is not allowed by Access-Control-Allow-Origin. 
http://bar.com/api?=x Failed to load resource

Incidentally, even though this call throws an error, it comes through fine on bar.com, so another option is basically just catching that error and ignoring it(?). Somewhat unfamiliar with JS though, so not sure if this will fail on other browsers?

Came across this: http://code.google.com/p/xmlhttprequest/source/browse/trunk/source/XMLHttpRequest.js – not sure if this is completely overkill for my use (overhead is pretty critical)?

  • 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-19T14:05:28+00:00Added an answer on May 19, 2026 at 2:05 pm

    Yes, this will always fail unless you have set the Access-Control-Allow-Origin HTTP header to define specific domains which are allowed to be accessed via XHR.

    One way you could work around this issue is by using script injection:

    function load_script(loc) {
       var s = document.createElement('script');
       s.src = loc;
       document.getElementsByTagName('head')[0].appendChild(s);
    }
    
    load_script('http://bar.com/api?=x');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a very simple and clear example of how to create an OCX
I need to be able to merge two (very simple) JavaScript objects at runtime.
I need to do a few very simple URL manipulations in Java. Like get
i have very simple problem. I need to create model, that represent element of
I need a very simple function to draw a bunch of lines with anti-aliasing.
I need a very simple c++ function that calls a lua function that returns
i need to build a very simple wizard that will import a text file
I need to build a very simple administration interface for maintaining website content. Not
I need to make a kext which does a very simple function. Whenever a
I am on jQuery 1.3.2 I need a very simple code. I have 4

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.