My site provides a javascript file which the users can include in their site. This javascript file in-turn calls my applications endpoint and fetches some content that is then inputted into the users' div
This is the code for the JS
(function(){
    $(document).ready(function(){
        var test = $('#FooBar');
        var id = test.data('id');
        $.get('http://example.com/serve/'+id, function(data){
            test.html(data);
        });
    });
})();
But when a user references this JS file on their own site, they get the following error:
XMLHttpRequest cannot load http://example.com/serve/qeFz7TvGlg. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
This is the sample HTML I created to test
<!doctype html>
<html>
    <body>
        <div id="FooBar" data-id="qeFz7TvGlg"></div>
        <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
        <script src="http://example.com/scripts/myjsfile.js"></script>
    </body>
</html>