3

I am trying to read a text file from the server using the below code. I am not able to access it but when I just have that text file local then its working fine. Please let me know what to do

$(document).ready(function(){
    $.get('http://.../admin/ReleaseNotes/FY13/UpcomingChanges.txt', function(contents) {
          $("#contentArea").val(contents);
    },'text');
 });
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1908522
  • 201
  • 1
  • 3
  • 7

1 Answers1

2

You are trying to request a document on a different domain to the one the request is being made from. Same Origin Policy will stop this request completing. There are ways to circumvent this policy though. You can find information in this answer: Ways to circumvent the same-origin policy

You could also try the following tutorial which will show you how to do a cross domain ajax request with YQL and jQuery.

http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-cross-domain-ajax-request-with-yql-and-jquery/

Community
  • 1
  • 1
ajtrichards
  • 29,723
  • 13
  • 94
  • 101