Solved

Is it possible to load an asp page externally from html?

Posted on 2003-11-20
6
209 Views
Last Modified: 2010-04-09
Is it possible to request an asp page to be ran from inside HTML?  

I have an asp page that loads data into an sql database, and I want this information inserted when visitors view my pages but some of the pages are HTML.  

I don't want any contents from the asp page to be shown.

Would this be possible with Javascript?

Thanks in advance

Neil
0
Comment
Question by:neilbarton
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
cj_nepenthe earned 250 total points
ID: 9789217
Hi,

Yes, this is possible using something similar to the script below.  This triggers an HTTP call to your ASP page whenever the page is loaded.

<script>
function insertData() {
   var objHttp = new ActiveXObject("Msxml2.XMLHTTP");
   objHttp.open("get", "http://myserver/insert-data.asp", false);
   objHttp.send();
   // (error checking goes here)
}
</script>

<body onload="insertData()">

0
 

Author Comment

by:neilbarton
ID: 9789345
Thanks for the quick response.  

The problem I am having is that on the html page I also have an external .js file which picks up some of the user details and saves them as cookies.  

Then when the ASP code is ran it should retreive some of the data from the cookies and some other from the sessions variables.   When the ASP loads it stores only the data from the sessional variable and leaves the fields from cookies empty even though I know that the cookies are there with data inside.

The code I am using to to grab the information from the cookies, seems not to work:

  objRS("Title") = Request.Cookies("Title")

The code I am using to grab information from the Session variables, works:

  objRS("UID") = Session("UID")

Is it possible to request cookies when loading a page using objHttp:open or <img src="thepage.asp" >.

Neil
0
 
LVL 1

Expert Comment

by:cj_nepenthe
ID: 9789527
That could be a problem, I don't think XMLHTTP sends the cookie data in the headers, because the request doesn't come directly from the browser.  It could also be a bit of a security hole.

Your best bet might be to get your cookie data using client-script from document.cookie, then pass it in parameters to your ASP page.

There are some handy client-side cookie manipulation routines here:
http://www.webreference.com/js/column8/functions.html
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 11

Expert Comment

by:Zontar
ID: 9789897
This is also MSIE-only.

The simpler and better solution is to use the .asp extension and a server-side include.
0
 
LVL 1

Expert Comment

by:cj_nepenthe
ID: 9790247
Server-side includes would be a much better solution if your server supports it, which it should if you're running ASP.
Unfortunately, you can only use SSI in .asp pages by default, so it might not work.  An .htm page process the SSI directives unless you play around with your web server settings.

But if you want to give it try, stick something like this at the top of your file and see what happens!

<!-- #include file="insert-data.asp" -->
0
 

Author Comment

by:neilbarton
ID: 9798903
Cheers found the answer.

<script>
  newImg = new Image();
  newImg.src = "http://myserver/insert-data.asp?quesr&string=parameter"+other.objectsValues+document.cookie;
</script>
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 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