-1

I want to load the content of a text file inside a JavaScript variable, but without having modify anything regarding webserver configurations.

I do not have any control over the http headers, on both websites.

The file is stored on a totally different webserver.

Currently I tried both .ajax and .get but I got Access-Control-Allow-Origin errors for both of them.

The file content is something like:

  term1|wow!
  term2|bleah,...!

I do have some control over the format of the file, but I don't want to transform it into something too complex to be edited by hand, and that would not be sortable by line.

sorin
  • 161,544
  • 178
  • 535
  • 806
  • It simply isn't possible if the content of the text file is not javascript or jsonp unless you use some sort of server-side proxy or YQL. – Kevin B Apr 26 '12 at 19:33
  • possible duplicate of [Cross Domain Ajax Request with JQuery/PHP](http://stackoverflow.com/questions/752319/cross-domain-ajax-request-with-jquery-php) – jrummell Apr 26 '12 at 19:35
  • @KevinB If it's not possilbe, just make it an answer, explaining why. Thanks. – sorin Apr 26 '12 at 19:38

1 Answers1

2

It isn't possible to request data from an external domain if it does not return the proper headers or a datatype that is allowed to be cross-domain such as javascript/jsonp, css, or images.

The only work-around is to use a server-side script to get the data for your page, or to use a public proxy service for this scenario such as YQL.

Kevin B
  • 94,570
  • 16
  • 163
  • 180