[thelist] Grabbing a file across domains

Christian Heilmann codepo8 at gmail.com
Wed Jan 10 02:34:21 CST 2007

> I have an ASP file which changes often.
> I want to be able to call it from php, htm, html and asp pages on the fly,
> and across multiple domains.
> I currently use the below script to call it in asp.
> Is there any way to call it using javascript, AJAX, or any other universal
> method?

XMLhttpRequest does not work across domains for security reasons,
therefore you need a server side proxy component like your ASP script
to pull the data. There is nothing stopping you to read the output of
the component with Ajax and display it though.

Your own server side proxy also enables you to filter our bad URLs,
cache content and give logical error messages.

If you can use JSON, there is no problem with cross-domains though as
it is JavaScript and you can create a SCRIPT tag on the fly.

Snook has done a good job collecting ideas:

There is also a hack available that uses hidden IFRAMES:

Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/

More information about the thelist mailing list