Solved

refresh XML content with ASP

Posted on 2013-05-20
4
662 Views
Last Modified: 2013-05-21
Hello experts,

It's been quite a while since I worked with ASP and XML and I am struggling to remember the simplest operations I used to do very easily.

Here is what I want to do:

I have an XML document and I want to display it with ASP without any change. (For example my test.asp will display exactly my test.xml)

The trick is I want this ASP page to refresh every 15 seconds and bring the latest XML document content. I was able to do that previously with:
   Response.AddHeader("Refresh",Head)

Can you share a sample code please? I don't have much time.

Thank you in advance
0
Comment
Question by:bozer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39183338
You can set a timer with vb but it eats up the cpu.  I would just use js like below.  If you want to get fancy, then jquery/ajax or js/ajax

<html>
<head>
<script type="text/JavaScript">
<!--
function AutoRefresh( t ) {
	setTimeout("location.reload(true);", t);
}
//   -->
</script>
</head>
<body onload="JavaScript:AutoRefresh(5000);">
<p>This page will refresh every 5 seconds.</p>
</body>
</html>

Open in new window

0
 

Author Comment

by:bozer
ID: 39183373
Thank you Padas,

Can you please share how to add the XML content ? My main issue is I am rusty with the methodology of doing that.
0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 150 total points
ID: 39183410
One way is xmlhttp post http://support.microsoft.com/kb/290591
<%
	DataToSend = "id=1"
	dim xmlhttp 
	set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
	xmlhttp.Open "POST","http://localhost/Receiver.asp",false
	xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
	xmlhttp.send DataToSend
	Response.ContentType = "text/xml"
	Response.Write xmlhttp.responsexml.xml
        Set xmlhttp = nothing
%>

Open in new window


Or pure ajax
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("GET","demo_get.asp",true);
xmlhttp.send();
}
</script>
</head>
<body>

<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<div id="myDiv"></div>

</body>
</html>

Open in new window


or jquery  http://api.jquery.com/jQuery.ajax/

<script>

$.ajax({
  url: "test.xml",
  cache: false
}).done(function( xml ) {
  $("#results").append(xml);
});
</script>

<div id="results"></div>

Open in new window

0
 

Author Closing Comment

by:bozer
ID: 39183582
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question