Google Answers Logo
View Question
 
Q: Creating my own newsfeed ( Answered,   0 Comments )
Question  
Subject: Creating my own newsfeed
Category: Computers > Programming
Asked by: jon_itmagic-ga
List Price: $50.00
Posted: 03 Oct 2002 06:28 PDT
Expires: 02 Nov 2002 05:28 PST
Question ID: 72009
I would like to create a newsfeed that delivers content to a 3rd party
webpage.

The site supplying the newsfeed uses ASP to generate the data, the 3rd
party site can only use HMTL & JavaScript.

I'm trying to call the newsfeed on the 3rd party site using the
following script:

<SCRIPT language="JavaScript"
src="http://www.###.com/eventlister.asp?OrgID=23"></SCRIPT>

The OrgID querystring is the unique id that identifies the correct
newsfeed.

The following ASP works in isolation and delivers the relevant data,
but I *think* it needs to be re-written for the JavaScript call to
interpret it and for it to write the relevant data back to the HTML
page. ???!

<%
Dim objRS,objConn,query

set objConn = server.CreateObject("ADODB.Connection")
objConn.Open	Application("ConnectionString")
Set objRS = Server.CreateObject("ADODB.Recordset")

query = "SELECT * FROM Organisation WHERE OrgID=" &
request.querystring("OrgID")

objRS.Open query, objConn, adOpenForwardOnly, adLockReadOnly,
adCmdText

if not objRS.EOF then %>
  <table width="250" border="0" cellspacing="0" cellpadding="0">
  <%
  do while not objRS.EOF
  %>
    <tr>
      <td><%=objRS("EventDate")%></td>
	  <td><%=objRS("EventDetails")%></td>
	</tr>
    <%
	objRS.MoveNext
  loop
  %>
  </table>
<%
else
  response.write "No event details available"
end if

objRS.close
set objRS = Nothing
objConn.close
set objConn = Nothing
%>

Please could someone re-write the above so that it is executed by the
JavaScript call and writes the relevent data back to the calling web
page. If I'm barking up the wrong tree, please tell me how to do it!

Many thanks,

Jon
Answer  
Subject: Re: Creating my own newsfeed
Answered By: prophet-ga on 03 Oct 2002 07:53 PDT
 
Hi Jon,

I think this method of creating a news feed will do just what you want
it to do.  The problem you're having comes from the fact that since
you are calling the asp page as a javascript, the content of the asp
page must be javascript, not pure HTML.

Here is the rewritten asp code:
<% 
Dim objRS,objConn,query 
 
set objConn = server.CreateObject("ADODB.Connection") 
objConn.Open Application("ConnectionString") 
Set objRS = Server.CreateObject("ADODB.Recordset") 
 
query = "SELECT * FROM Organisation WHERE OrgID=" &
request.querystring("OrgID")
 
objRS.Open query, objConn, adOpenForwardOnly, adLockReadOnly,
adCmdText
 
if not objRS.EOF then %> 
  document.write('<table width="250" border="0" cellspacing="0"
cellpadding="0">');
  <% 
  do while not objRS.EOF 
  %> 
  document.write('<tr><td><%=objRS("EventDate")%></td><td><%=objRS("EventDetails")%></td></tr>');
    <% 
 objRS.MoveNext 
  loop 
  %> 
  document.write('</table> ');
<% 
else 
%>
  document.write('No event details available');
<%
end if 
 
objRS.close 
set objRS = Nothing 
objConn.close 
set objConn = Nothing 
%> 

I tested this code in Internet Explorer and Netscape 6 and both work
perfectly.

Note: The call to the javascript will not work if it appears within
the HEAD of the 3rd party's HTML document.  The only way to get the
javascript to write the news feed content into the 3rd party's site is
to have them put the call to the javascript in the BODY of their HTML
document, exactly where they'd like the news feed to appear. For
example:
<html>
<head>
<title>Test Page</title>
</head>
<body>
Test content. News feed appears below.<br>
<SCRIPT language="JavaScript" src="test.asp?OrgID=23"></SCRIPT>
</body>
</html>

I hope this answers your question.  Good luck.

Prophet
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy