Hacker News new | ask | show | jobs
by shajith 5754 days ago
I'm curious: how do you get around crossdomain XHR limitations using <script> tags? Thanks!
1 comments

<script> tags aren't subject to cross-domain restrictions. Think about it - all those website statistics scripts are hosted on external servers, but their Javascript gets executed just fine. By dynamically inserting <script> tags into the page, you can force Javascript from another domain to execute in your domain.
Got it, thanks. I finally got around to learning JSONP.

JQuery's $.ajax API handles it automatically for you too (if you use the 'jsonp' or 'script' dataType options), which is very nice.