So basically we are trying to read a text or html file from external server which we don't have control off .
We are using script src tag to fetch the file but we are unable to read it
<script type="text/css" id="Script1" src="http://www.thirdparty.com/example.txt" ></script>
like in this screenshot you can see we are fetching a random txt file and we are getting a response but through javascript we are unable to read it .
Screenshot Image link
So now our motive is to read the example.txt file and store the content into a javascript variables.
Things that we have already tired but didn't work due to some or other reason
Using XHR and jQuery load function
$(document).ready(function () { $("#container").load("http://www.thirdparty.com/example.txt"); });
but as I said its third party server and we don't have control over it , that's due to Cross-Origin XMLHttpRequest we are not getting any response from the server. by the way is there anyways to eliminate origin header from the xhr request ?
Using proxy server wont work because of ip issue and cookies needs to be send from the client side.
Getting innerhtml and innertext of the script tag but it didn't return the response rather it give code between tag which is not required .
P.S. we what something client side javascript bases solution not serverside due to some specific requirements .
thanks in advance for helping