Solved

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

Posted on 2003-11-20
6
210 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

830 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