Get a JSON file from URL, XMLHttpRequest cannot load error

I need to read a JSON file from URL and display. I have read a lot of posts but still couldn't fix the problem.

url :

I face this error : XMLHttpRequest cannot load

The code is below

$.getJSON("", function(data){

I have tried adding to the url


and making it a jsonp, still no luck. I have also used

<meta http-equiv="Access-Control-Allow-Origin" content="*" />

still no luck.

Is there anything that we need to do at the server side? People who have faced such an error and have found a solution, Help me out please! Thanks a lot!


You cannot make cross-domain AJAX requests like that due to security reasons. So if you want to load content from another domain, you will have to use a workaround: JSONP (more info, example)

Use the following code for the AJAX request:

    url: '',
    type: 'GET',
    jsonpCallback: 'myCallback',
    dataType: "jsonp",
    success: function(data) {

In order for this to work, you will have to wrap the JSON data in parentheses and add the callback name at the beginning:

myCallback({ ... JSON ... })

EDIT: Just noticed you already tried to use JSONP... Well, at least the above code works for me, perhaps you want to give it a try. ;)

Need Your Help

create_string_buffer how to get used size

python ctypes string-length

How can I determine the used size/length of a buffer created with create_string_buffer?

Uncaught Error: When the modifier option is true, validation object must have at least one operator

javascript mongodb meteor

trying to read between StackOverflow and the documentation of meteor-simple-schema but can't find a solution. I'trying to insert data in the Meteor.users collection through a form. But keep getting...