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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:57:03+00:00 2026-06-10T08:57:03+00:00

I have a working HTML5/JS app that I’m trying to port to the browser

  • 0

I have a working HTML5/JS app that I’m trying to port to the browser for a demo. The app was built to run in a vehicle and used the vehicle manufacturer’s network API for get/post requests.

For the browser version of this, I’m trying to use jQuery for get/post. However, I’m immediately running into issues.

XMLHttpRequest cannot load http://<API I AM CALLING>. Origin null is not allowed by Access-Control-Allow-Origin.

I’ve looked into the same origin policy, but still do not fully understand it. I can browse to the URL being used, and see the JSON I’m trying to retrieve.

Looking around the web, a lot of people suggested specifying JSONP as the dataType in my ajax call. I gave this a shot, with no success.

            $.ajax({
                url: url,
                type: "GET",
                dataType: "jsonp",
                success: function (data, textStatus, jqXHR) {
                    log("success getting JSON from " + url);
                    success(data);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    log("error getting JSON from " + url + ", code " + JSON.stringify(jqXHR));
                    log("textStatus is " + textStatus);
                    log("errorThrown is " + errorThrown);
                },
            });

An error shows up in my console:

Uncaught SyntaxError: Unexpected token : 

After that, my error callback is used.

error getting JSON from http://<API I AM CALLING>, code {"readyState":4,"status":200,"statusText":"success"}
textStatus is parsererror
errorThrown is Error: jQuery180006523256213404238_1346098086632 was not called 

It looks like the server is responding with the JSON data I need. But, I’m guessing that jQuery is expecting this data to be wrapped in a function so it fails to parse it.

I have no control over the server whose API I am calling. Since the data is coming back to the browser, I feel like there’s got to be some way to access it.

Note:
App is only targeted for webkit browsers, I don’t need to support any others. Leaving dataType as “json” only causes problems in Chrome but Safari seems to work fine due to different security policies. Looking for a code workaround, not simply launching Chrome with special arguments. This still happens in Chrome even when I host my code on Apache, so it’s not just limited to me trying to open index.html locally.

  • 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-06-10T08:57:05+00:00Added an answer on June 10, 2026 at 8:57 am

    One possible solution would be to write a service that proxies the JSON service you want and returns JSONP. I’ve written many proxy services like this so I can get around the same origin policy.

    For instance: http://high-cloud-3702.heroku.com/

    This service is a jsonp proxy for urban dictionary.

    You can write a proxy like this in Sinatra very easily and host it on Heroku for free.

    The key to a proxy like this is this code:

    get '/' do
      callback = params.delete('callback') # jsonp
      json = <function_to_get_data_here>.to_json
    
      if callback
        content_type :js
        response = "#{callback}(#{json})" 
      else
        content_type :json
        response = json
      end
      response
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to have a small chat app(which was almost working), that uses PHP,
Here is the problem I have an app that is working in every browser
I have a rails app that is working fine except for one thing. When
I have code that works in a .NET 3.5 app that isn't working when
I'm working on an HTML5 mobile app and I initially have the background of
I'm new to MVC land, and have an app that i'm working on. i
I have a web app that I'm working on that I would like the
I am working on an app that have this code on a view file
I have an HTML5 iPad app that works offline. The app essentially consists of
I have Web App that cache as per HTML5 on iPhone and Android and

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.