-1

I am trying to get a txt file from another server and load it to a div using jquery ajax.

$("#div1").load("www.serverA1d.com/demo_test.txt");

I get

Origin http://www.mysiteA.com is not allowed by Access-Control-Allow-Origin.

I don't have control over the serverA1d or the demo_test.txt. How can I retrieve this txt file using ajax ?

jayt.dev
  • 975
  • 6
  • 14
  • 36

1 Answers1

0

This can be done, but it's problematic. By default, servers and browsers don't allow this, due to security concerns.

Here's more on the concept of Cross-Domain AJAX calls...

Make cross-domain ajax JSONP request with jQuery

And, here are some ways you can potentially work around this...

jQuery AJAX cross domain

Community
  • 1
  • 1
Jacob
  • 383
  • 1
  • 5
  • 11