ahosang
10-07-2003, 10:18 PM
I am trying to send back a text/javascript response(it's a dynamically loaded <script> tag) to the user. The variable HTML will end up as a javascript string representing the contents of a multi-line file(probably just a .html file, could be .pdf). Please can someone fill in the part that reads off the file on the server. Please remember that it's important to strip all returns, line separator because these would cause error in javascript.
Oh, and I don't practise ASP, only JSP, but I got this far from a book. Any other errors, please point out.
Here's my attempt.
getdata.asp:
<% Response.ContentType="text/javascript"%>
var div="<%= Request.QueryString("div") %>";
<% Dim HTML=""
Dim url=Request.QueryString("url")
Set file=Server.CreateObject("System.FileSystemObject")
Set fileContents=file.getFile(url)**NOTES - NOW I'M NOTE SURE - MAY HAVE TO USE BINARY READ OR LINE-BY-LINE READING**
** MAYBE EVEN TEXTSTREAM OBJECT - NEED TO ASK AN ASP EXPERT TO DO THIS PART**
** AFTER YOU OBTAIN THE FILE CONTENTS WITHOUT LINE SEPARATORS, SET 'HTML' VARIABLE TO THE FILE CONTENTS, IT ENDS LIKE BELOW**
%>
var HTML="<%= HTML %>";
doUpdate(div, HTML);
Oh, and I don't practise ASP, only JSP, but I got this far from a book. Any other errors, please point out.
Here's my attempt.
getdata.asp:
<% Response.ContentType="text/javascript"%>
var div="<%= Request.QueryString("div") %>";
<% Dim HTML=""
Dim url=Request.QueryString("url")
Set file=Server.CreateObject("System.FileSystemObject")
Set fileContents=file.getFile(url)**NOTES - NOW I'M NOTE SURE - MAY HAVE TO USE BINARY READ OR LINE-BY-LINE READING**
** MAYBE EVEN TEXTSTREAM OBJECT - NEED TO ASK AN ASP EXPERT TO DO THIS PART**
** AFTER YOU OBTAIN THE FILE CONTENTS WITHOUT LINE SEPARATORS, SET 'HTML' VARIABLE TO THE FILE CONTENTS, IT ENDS LIKE BELOW**
%>
var HTML="<%= HTML %>";
doUpdate(div, HTML);