Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 06:51 PM
Registered User
 
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default interval timed calls to asp routines

Having read Imar Spaanjaars excellent note on "sharing a server-side variable with client-side" I can see a solution to this problem but I wonder if there is a more 'direct' approach.

I need to use an interval timer to change a short text quotation. These quotations come from a mySQL database table. I have set up an interval timer with javascript and a sql call to extract the random quotation. I need to connect the two. I had hoped to call the asp routine from client side Javascript but unless I have missed something, that needs Remote Scripting but the server I am using does not seem to support RS.

I see that I can read the set of strings (not too many at present) into a session or application array at run time and choose one of those at random at intervals.

But is there some way of triggering some asp code from an interval timer and passing the result of that call back to the client side javascript thus bypassing the need to hold the quotations in a session array?

any help would be appreciated.

Regards

Nick

 
Old October 29th, 2004, 03:18 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You have two basic choices, either load all the quotes on first access onto the client and then select one at random entirely client side, you never need return to the server. Alternatively have something like an iframe or frame whose content is refereshed periodically, each time a different quote is displayed.
You don't need remote scripting.

--

Joe
 
Old October 29th, 2004, 03:48 AM
Registered User
 
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The quotes are only one liners - so I propose to change the content of a <span> element once I get a fix (as per your other post)and pull out a random quote on the client side as you suggest. I had intended to load the quotes into an application array but I see that application level arrays aren't allowed.

Nick

 
Old November 4th, 2004, 01:48 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Nick,Joe
I have another approach to your question.

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
function NextQuotation() {

var obj = new ActiveXObject( "Microsoft.XMLHTTP" );
var url = "http://myurl/GetQuotation.asp"
obj.open( "POST",url, false );
 obj.send();
 nextquotation=obj.responseText
 alert(nextquotation);
}
</SCRIPT>
<form name="test">
<input type="text" name="quotation_id" >
<input type=button name="getQuote" onclick="NextQuotation()">
</form>


And my "GetQuotation.asp" ASP page is like
<% response.write "hii" %>

Since You want to get quotation from the database (MySQL) u can pass the quotation id to the url i.e (GetQuotation.asp page) and get then next quotation and display the quotation randomly .
Hope ,It will help to find the solution.

Cheers :)



vinod
 
Old November 4th, 2004, 05:28 PM
Registered User
 
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Vinod. I will have a closer look at that. Does using an ActiveXObject present problems with non IE browsers? I need to do a bit of work to understand that side better.

I do have Joe's suggestion working OK now but all ideas help.

Thanks - Nick

 
Old November 4th, 2004, 08:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

ActiveX controls only work with IE.

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 5th, 2004, 03:55 AM
Registered User
 
Join Date: Oct 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That is what I wondered and I can't be sure that is all my clients will use.
Thanks
Nick






Similar Threads
Thread Thread Starter Forum Replies Last Post
Routines in MYSQL js_newbie MySQL 4 April 1st, 2007 07:32 PM
make an image rollover that calls an asp page gavmc Classic ASP Basics 0 December 15th, 2005 12:13 PM
ASP Page hangs when calls a vb component king05 Classic ASP Components 0 March 28th, 2005 01:07 PM
Converting ASP calls to ASPX OldCoder Classic ASP Basics 1 October 23rd, 2004 03:04 PM
A date interval with a date interval query spinto SQL Server 2000 7 May 15th, 2004 04:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.