Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read a text file from the url using Jquery

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');
 });
like image 776
user1908522 Avatar asked Nov 25 '25 07:11

user1908522


1 Answers

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/

like image 150
ajtrichards Avatar answered Nov 27 '25 22:11

ajtrichards



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!