ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 28th, 2002, 02:20 PM
Nestor Nestor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 6 Nestor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Running ASP script in background

Hi everyone,

First of all I want to thank all of you in this community; By reading the WYSIWYG threads I fully undestood and set up the html editor as part of my developments. They were really helpfull and now I am using it all the time.

Now my question, I have a form with a lot of fields that I need to post to a "different server" and I need to run an asp script in the background while submitting the Form (to tell my server that the information was submitted and do extra processing including session.abandon) - the script is another asp page, so I am using the window.navigate method to execute the script (I don't want to open a new window and then close it after running the asp script).

Is there another better way to do this?

My vbscript code is:
<script LANGUAGE="vbscript">
<!--
Sub form1_onsubmit

set oNavWin = window.navigate ("myLastScript.asp")

End Sub
-->
</script>

Thanks in advance for your help,

Nestor

Last edited by Nestor : August 6th, 2002 at 12:12 PM.

Reply With Quote
  #2  
Old July 28th, 2002, 09:54 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Hi,
If you want to run two scripts when a form is submitted, then why not just use an include directive to include one?

<!-- #INCLUDE file="myscript.asp" -->

Or, you could use frames: Have one visible and one hidden frame and set the location.href attribute of the hidden frame to the script you want to execute when the form is submitted...

Reply With Quote
  #3  
Old August 6th, 2002, 12:10 PM
Nestor Nestor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 6 Nestor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Mytch,

I use the include file, something like this:

<!--

Sub form1_onsubmit

<!--#include file="myscript.asp"-->

End Sub

-->

but it is including the file when the page is loaded and I want to include (or execute the script) when submiting the form.

Any idea??

Thanks in advance.

Nestor

Reply With Quote
  #4  
Old August 15th, 2002, 07:02 PM
rajeevrao rajeevrao is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bangalore
Posts: 30 rajeevrao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to rajeevrao
You could use javascript ..

<form onsubmit="???">
??? = something that opens a new window for some time (say 2 secs settimeout(2000,xyz)) and which includes the file you wanted ..
I'm currently busy .. I'll give the full code later (if ya need)
Good Luk !
__________________
Rajeev

Reply With Quote
  #5  
Old September 3rd, 2002, 08:41 AM
Nestor Nestor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 6 Nestor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Rajeev, I will wait for your code.!

Reply With Quote
  #6  
Old September 3rd, 2002, 03:47 PM
chaliepaka chaliepaka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 5 chaliepaka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XMLHTTP

Dude, whenever I have to do what you are trying to do I always use the XMLHTTP object because it keeps everything in the background for the user. Below please find some sample code from Microsoft on how to do this. You can look it up yourself at:
http://msdn.microsoft.com/downloads...TTP/Default.asp

good luck!

sample:

<P>This sample application allows you to enter a database server name, a
database name as well as a SQL statement which will be executed and
returned to you in an XML representation. This sample will generate
override the default behavior of the HTML <form> element and will
generate an XML-based request that will be passed to the ASP page for
subequent processing.</p>

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">

function frmQuery_onclick() {

// Make sure that it was a click on the submit button that triggers this action
if( event.srcElement.type == "submit" ) {

// Convert the input parameters into the appropriate XML string
var strRequestXML = "<request><computer>" + frmQuery.txtComputer.value + "</computer>";
strRequestXML += "<database>" + frmQuery.txtDatabase.value + "</database>";
strRequestXML += "<sql><![CDATA[" + frmQuery.txtSQL.value + "]]></sql></request>";

// Show the request XML
divOutputRequest.innerText = strRequestXML;

// Create an instance of the XML HTTP Request object
var objXMLReq = new ActiveXObject( "Microsoft.XMLHTTP" );

// Prepare the XMLHTTP Request object to issue a synchronous HTTP POST
// request to the URL specified by the <form> action attribute
objXMLReq.open( "POST", frmQuery.action, false );

// Execute the HTTP POST request, passing strRequestXML as the request body
objXMLReq.send( strRequestXML );

// Drop the returned XML into our <div> output element
divOutputResponse.innerText = objXMLReq.responseText;

// Cancel the default action of the <form> element
return false;
}
}

</SCRIPT>

<!-- This is the HTML form that will be used to gather up the parameters to
pass to the ASP page as part of an HTTP POST request. If you want to try
the VBScript version of the server side code, change the action attribute
of the <form> element from runQueryJ.asp to runQuery.asp -->

<FORM action="runQueryJ.asp" method="post" id="frmQuery" language=JavaScript onclick="return frmQuery_onclick()">
<LABEL>Computer name:</LABEL><INPUT type="text" id="txtComputer" name="txtComputer" maxLength="50"><BR>
<LABEL>Database name:</LABEL><INPUT type="text" id="txtDatabase" name="txtDatabase" maxLength="20"><BR>
<LABEL>SQL statement:</LABEL><INPUT type="text" id="txtSQL" name="txtSQL" maxLength="200"><BR>

<INPUT type="submit" value="Submit" id=btnSubmit>
</FORM>

Reply With Quote
  #7  
Old September 4th, 2002, 08:43 AM
chaliepaka chaliepaka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 5 chaliepaka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation FYI on XMLHTTP Request object

The code in my sample is just one way to use the object. How you actually use it depends on the version of XML the user or server has installed and it depends on whether you want to do it server side or client side. When I looked at the code I posted from MS I noticed that it would only work on an older version of XML and that version would have to be installed on the client. That is why I wanted to give you a little more info on your options. I didn't want you to cut and paste this code and have it blow up on you!

Reply With Quote
  #8  
Old September 5th, 2002, 12:58 PM
Nestor Nestor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 6 Nestor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb Final question

Thanks for the info and the code. I have been reading. It's really nice to learn and implement something new.

Now I think I have been making my life very difficult with this simple task. After tuning my development and implementing some tips received in this list I came with one last and final question or problem:

At the end of the process the user gets a FORM that needs to be submitted to a Different Server, not mine, and using Method=Post.

So the ONLY thing I need to do is to execute a Session.Abandon after the form is submitted. How can I address that?

I am using the following script but it is not working.

<script LANGUAGE="vbscript" RUNAT=Server>
<!--
Sub form1_onsubmit

Session.Abandon

End Sub
-->
</script>

Any idea???

Many thanks in advance.

Nestor

Reply With Quote
  #9  
Old September 11th, 2002, 08:53 AM
chaliepaka chaliepaka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 5 chaliepaka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question session.abandon?

What is it that you were expecting to happen? All session.abandon does is clear the session vars and cookie values.

Reply With Quote
  #10  
Old September 15th, 2002, 02:13 AM
Nauman Nauman is offline
Twenty Seven
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Multan, Pakistan
Posts: 103 Nauman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 33 m 2 sec
Reputation Power: 17
Send a message via ICQ to Nauman
Re: session.abandon?

Hello...

You can do it with javascript...

On the onclick event of the submit button open the new window and on this windows execute sessoin.abandon and set the timere to 1 second close window...

ok..

Thanks...
Nauman AHmed

Reply With Quote
  #11  
Old September 16th, 2002, 02:11 PM
alpha_kappa alpha_kappa is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Arizona
Posts: 2 alpha_kappa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The frames option is interesting. If you use a frameless page and you don't want to manage framesets, here's how you can do it : Use the <IFRAME> tag and set the visibility of that frame to hidden, and the URL to about:blank. So you will have a floating frame in your page that doesn't show up and doesn't load.

When you want some script to execute in the background, just use a javascript to change the location.href of the hidden frame ( you will have to name the frame to refer to it) to the script you want to execute.

Building on the concept, you can even send variables using POST. (using querystrings is easy, but a little tweaking will allow you to send varibles to the floating frame using POST)

So what if you want to refresh the main page after the hidden script has executed -> say, to tell the user that the submission has been accepted blah blah? Just have the ASP code in the script generate a few lines of javascript which will change the location of the parent page to the appropriate one. Use window.parent.location to achieve this.

Anil

URL

Reply With Quote
  #12  
Old September 18th, 2002, 08:28 AM
Nestor Nestor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 6 Nestor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Thanks it worked!

THANKS this works great and I solved my problem and even I improved it my application.

Thanks again to ALL!

Nestor

Reply With Quote
  #13  
Old June 1st, 2004, 05:01 AM
keryavuz2 keryavuz2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 keryavuz2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Nestor,

Could you please explain the solution to me.
I'm trying to do same thing I think.

I need to run asp script to create xml data which runs about 20 minutes on the server.
I don't want user to wait until finish. When process is done. I will inform via mail that the job has finished and xml is ready.
Is that possible.

Thanks

Kamil

Reply With Quote
  #14  
Old July 8th, 2004, 11:54 AM
lenny_2003 lenny_2003 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 lenny_2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Me too..

Hi folks.
I am also trying to achieve this same thing..

Ideally:

> user clicks submit.
> user gets a page stating "script in progress"
-- script is running in background
> server emails user when script complete


Whilst I can follow much of the above items, they offer varying solutions - could somebody tie it up for me!

Many thanks!

Leon

Reply With Quote
  #15  
Old July 8th, 2004, 12:27 PM
StudioReview StudioReview is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 30 StudioReview User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
Be careful

You can run the MSXHTML object either synchronously or asynchronously. Make sure you do the latter or your page will be "processing" forever.
__________________
Tivo Codes, Hacking the Tivo, and Adding a Second Drive to Your Tivo.
All this information at www.TivoSpy.com !

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Running ASP script in background


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap