i'm a relative newbie to javascript and the more advanced techniques of Web
dev't so bear with me. what i'd like to accomplish is twofold..
1. in client-side JS in an aspx file, i'd like to POST straight html via the
Request object down to an asp page that runs server-side script.
2. i want this server-side script to retrieve the html from the Request
object, place it into the Response object in such a way that i can save/open
it as an Excel file. i'd prefer to have the script force an Open/Save dialog
to open and prompt me for what i want to do.
this is what i have and i've tried a zillion variations but i just can't get
it to work.. the version below errors out on the doc.save with a message
saying i need a high-level element.
client-side aspx..
var str = document.all.Table2.outerHTML;
alert(str); // i get the html
var req = new ActiveXObject("Microsoft.XMLHTTP");
alert(req); // valid object
var doc = new ActiveXObject("Microsoft.XMLDOM");
alert(doc); // valid object
doc.load(str);
req.open("POST", "http://localhost/testServSideXL/WebForm1.asp", false);
req.send(doc);
return req.responseXML;
server-side asp (WebForm1)..
<%@ Language="javascript" %>
<%
var fileName = "MyReport-Excel Export";
fileName = fileName + ".xls";
Response.AddHeader("Content-disposition", "Attachment; filename=" +
fileName);
Response.ContentType = "application/download";
var doc = Server.CreateObject("Msxml2.DOMDocument");
doc.load(Request);
doc.save(Response);
// var innerHTML = doc.xml;
// Response.Write(Request);
// Response.Write(innerHTML);
%>