Out of curiosity... Anybody using ASP and XMLHTTPRequest?

Just out of curiosity, I was wondering if anyone has deployed any applications using good ol' ASP and XMLHTTPRequest. I've started doing it with a couple of sites I'm working on, and am finding it's amazingly fast and starts introducing the concept of an "application" to the web without all the overhead of let's say a Java-based framework like AF, or even the sophistication of Ruby on Rails.

Points will be awarded based on discussion and good, working examples.

Thanks!

GoofyDawg
LVL 12
GoofyDawgAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kiddangerCommented:
I'm not sure what you're looking for but here is a simple example of grabbing an image from a remote site, saving it, reloading it from file and then displaying it, all in binary mode.

This is the link: (notice you cannot view the source)
http://kiddanger.com/lab/getimage.asp

This is the source code:

<%@ Language=VBScript %>
<%
function GetBinaryData(filename)
  Response.ContentType = "image/gif"
  dim HTTP
  set HTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
  HTTP.Open "GET", filename
  HTTP.Send
  GetBinaryData = HTTP.responseBody
  set HTTP = nothing
end function

sub SaveBinaryFile(binaryData, path)
  dim fso, bStream
  set fso = server.CreateObject("Scripting.FileSystemObject")
  set bStream = server.CreateObject("ADODB.Stream")
  bStream.Type = adTypeBinary
  bStream.Open
  bStream.Write binaryData
  if not fso.fileExists(path) then
    bStream.SaveToFile path, adSaveCreateNotExist
  else
    bStream.SaveToFile path, adSaveCreateOverWrite
  end if
  bStream.Close
  set bStream = nothing
  set fso = nothing
End sub

Function ReadBinaryFile(FileName)
  Const adTypeBinary = 1
  Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")
  BinaryStream.Type = adTypeBinary
  BinaryStream.Open
  BinaryStream.LoadFromFile FileName
  ReadBinaryFile = BinaryStream.Read
End Function

Const strPath = "c:\domains\kiddanger.com\e\"
dim path, gifdata, file, remoteFile, imgdata
remoteFile = "http://www.google.com/intl/en/images/logo.gif"
imgdata = GetBinaryData(remoteFile)
file = "logo.gif"
path = strPath & file
SaveBinaryFile imgdata, path
gifdata = ReadBinaryFile(path)
Response.ContentType = "image/gif"
Response.Buffer = True
Response.Clear
Response.BinaryWrite gifdata
Response.Flush
%>

This is a link to grab a local (server) file and display it in a textarea.  There is a link at the bottom of the page to view the source.
http://kiddanger.com/lab/geturl2.asp

This is the file it grabs:
http://kiddanger.com/lab/plainjane.html

You can view the source to see it is an HTML file but the HTML markup is stripped when it is called from geturl2.asp.
GoofyDawgAuthor Commented:
That's cool, but I'm actually looking for created on a broader scale - perhaps some web application that was built using XMLHTTPRequest - Mind you - and I'm sorry I didn't mention this - I'm looking for something cross-browser as well...

GoofyDawg
kiddangerCommented:
Perhaps you should be more specific since 'web application' is vague.  Also, that's not cross-browser.  Test for the support and then branch, as you would with any app.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

GoofyDawgAuthor Commented:
Hmm...

I hate to use the buzz word of the day, but to be specific, I'm essentially talking about AJAX. I'm looking to see if anyone has done something along these lines using ASP, such as a dedicated (and I'll correct myself here) web-based application using ASP as the "app" layer, then JavaScript/XMLHTTPRequest to handle the content.

Thanks for the input so far...

GoofyDawg
Anthony PerkinsCommented:
For the record and as has been pointed out already you should be using ServerXMLHTTP instead of XMLHTTPRequest
kiddangerCommented:
GD...

I haven't done any 'ajax' per se and I know it's the buzz word of the day but it's not anything new.  MSFT was doing it years ago.  It's called remote scripting.  I have an article somewhere.  In fact, I believe I already posted a link to it here on a different question.

Here, I found it.  You should read this article.  It's not only accurate and informative, it's quite humorous.
http://www.eggheadcafe.com/articles/20050528.asp

The idea is to add/update elements into your page without refreshing.  It still uses the HTTPRequest but MSFT one way and FF (for example) uses it with what is built in.  Since IE doesn't have it built-in, the ActiveX is required.  FF couldn't use the ActiveX, even if it didn't have support built-in because FF doesn't support ActiveX.  That was my reference to my previous comment re: Test for support and then branch meaning test for what the browser supports vs testing for the browser name and version and then branch accordingly in your app.

This was the other thread.  You may find it useful.
http:Q_21476930.html

GoofyDawgAuthor Commented:
That article is dead-on. Thanks for the reference. Just for clarity, I'm not new to remote scripting, but the funny thing is that up until recently, I hadn't heard of a lot of sites that were employing it to a very large degree, so I was curious to see if people were actually using it - especially with basic ASP. Now there seems to be this craze over it, especially in the non-MSFT platforms.
kiddangerCommented:
I would agree.  There seems to be a craze but I think mostly because HTTPRequest is builtin to FF and some others so it's another "We have something IE doesn't have."  The funny part is they're crazy over something originally from MSFT.  It just has a new name.  I'd bet if they all knew where it originated, the craze would be over, for the most part.

It is nice to update without refreshing but it's a lot of extra work and debugging.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GoofyDawgAuthor Commented:
What I've personally found is that your client (or whoever you're building for) has to accept the fact that changing content will not cause a page refresh - goes back to that notion of an application. I had a lot of explaining to do recently with a client when I rebuilt the content management section of their site. They kept on saying "it's on the same page!" :)

With regards to you last statement, what I found easiest was to use my ASP pages simply as content providers, and letting JavaScript and CSS handle display. But you're right, with AJAX, you do introduce another layer, so it can be a bit challenging.

GoofyDawg
kiddangerCommented:
Thank you GD.
GoofyDawgAuthor Commented:
Not a problem. Thanks for the discussion.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.