Thursday, 22 August 2013

Error when I am using getJson.

Error when I am using getJson.

I wrote a javascript code to get a Json object from a url. And my code is
like this:
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON('url_address', {}, function(data) {
// do something
});
});
});
});
</script>
And I am using Google Chrome browser. And I can get the json data
correctly if I just enter the url in my browser.
But when I debug this code, I got an error message:
XMLHttpRequest cannot load 'url_address'. Origin null is not allowed by
Access-Control-Allow-Origin.
I don't know what's wrong with it.

No comments:

Post a Comment