Print Page | Close Window

Read data back from URL

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=31443
Printed Date: 28 March 2026 at 8:55pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Read data back from URL
Posted By: lee2121
Subject: Read data back from URL
Date Posted: 13 January 2017 at 3:03pm
Hello, If i run the following code in an ASP page it loads the file (stored on local server) and outputs the text as expected;

<p id="demo"></p>

<button type="button" onclick="loadDoc()">Load Feed</button>

<script>
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "XML_TEST.xml", true);
  xhttp.send();
}
</script>

I need to run this from a URL not a local file. The URL has the exact same data and if i run the URL in a browser i get the data displayed in XML in the browser but when i change my code to fetch the data from the URL nothing happens.

<script>
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "https://test.httpapi.com/api/domains/available.xml?auth-userid=user&api-key=key&domain-name=domain&domain-name=domain2&tlds=com&tlds=co.uk", true);
  xhttp.send();
}
</script>

any ideas please how i can get this to work?



Replies:
Posted By: WebWiz-Bruce
Date Posted: 16 January 2017 at 10:46am
This looks to be JavaScript running client side rather than ASP code which would run server side.

Browsers often block client side JavaScript from running cross domain for security to prevent XSS vulnerabilities.

In addition running client side as JavaScript would expose your login credentials to the end user.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net