Solved

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

Posted on 2003-11-20
6
207 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now