I have a script file loaded from mydomain.com that makes ajax requests to that domain. The script though is loaded on some other domain which initializes it and then tells it when to make the requests. I'm running into issues though because the browser is thinks it's a cross domain request. I thought that whatever domain the script file was loaded from was able to make requests back to that origin? Here's some code as an example:

Your script is violating the cross-domain restriction by by being served from one domain, but requesting a script on another domain.

What's the right approach?

There are two possibilites:

Place both the running script and the called script under the same domain.

Use dataType = "jsonp" to bypass the restriction. jQuery will perform some magic (replacing the call with an inline script reference in the format of <script src="mydomain.com/endpoint" /> to make this work.