CORS or Cross Origin Resource Sharing

The bitly API supports CORS, or Cross Origin Resource Sharing.

Historically, Javascript AJAX requests were restricted to a same domain origin policy. This meant that your website at http://mysite.com/ could not make AJAX requests to https://api-ssl.bitly.com/, since they were not the same domain.

With the introduction of HTML5 and advancements in modern browsers, CORS allows website owners to control who can access data via Javascript AJAX requests. In this way, CORS functions like Flash's Cross Domain Origin Policy. The latest version of the bitly API (V3) supports CORS requests from any domain.

Here is some basic example Javascript to get you started:

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api-ssl.bitly.com/v3/.....");
xhr.onreadystatechange = function() { 
    if(xhr.readyState == 4) { 
        if(xhr.status==200) {
            console.log("CORS works!", xhr.responseText);         
        } else {
            console.log("Oops", xhr);
        }
    } 
}
xhr.send();

You can also read more about CORS here.