473,624 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying Ajax data and using timers properly

Hi Guys,

I'm new to Javascript and have a couple of questions that I hope
someone could quickly answer for me.

First, I'm trying to modify an example Ajax script to fit my needs.

The script is located here:

http://ajaxify.com/run/time/periodicRefresh/

I'm trying to display return data from my existing script, and I'm a
little confused on how to display the returned variables within my Web
page. Currently the author of the 'example' script has the following
code embedded within the HTML:

<form action="/">

<div id='customTimeL abel' class='timeLabe l'></div>

<div align="center">
<input type="hidden" id="customTime " value="Refresh" />
</div>

</div>
<div align="center"> </div>

</form>

The author displays this form and also has a button to create an
additional action when the button is pressed. I removed the button and
just want to display the variables, I do not want to have a form as he
did. Is there a alternate way of doing this? When I embed this in my
code it takes up too much real estate on the Web page.
Second, there is a setInterval timer used that periodically goes to
the server and refreshes the data. I have created a function,
'volup()' that stops the timer 'clearInterval( interval)' and displays
a new message for a few seconds, then my script is supposed to restart
the setInterval timer. Everything seems to work ok with the exception
of the setInterval restart. Could someone have a look at my code and
give me some suggestions? The problem is on the last line of the
volup() function, this command never seems to restart the timer. Also
I've noticed that my setTimeout timer can become very erratic at
times, not following my specified timing of 3 seconds, but this only
happens once in a great while and is very intermittent.

Thanks in advance,

Shawn
ajaxCaller.shou ldDebug = false;
var timeURL = "cgi-bin/test?h=1";
//var timeURL = "tickercontent. txt";
window.onload = function() {
// $("defaultTime" ).onclick=reque stDefaultTime;
// $("customTime") .onclick=reques tCustomTime;
requestCustomTi me();

interval=setInt erval(requestCu stomTime, 1500);
}

function volup(){

clearInterval(i nterval)
showCustomTime( "Change Source", "");

a="requestCusto mTime();"

setTimeout(a, 3000);
clearTimeout(t)

interval=setInt erval(requestCu stomTime, 1500)

}

function requestCustomTi me() {
var callingContext = Math.round(Math .random() * 100);
ajaxCaller.getP lainText(timeUR L, showCustomTime) ;
}

function showCustomTime( text, callingContext) {
var customTimeLabel = $("customTimeLa bel");
customTimeLabel .innerHTML = text + "." + callingContext;
}

Sep 27 '08 #1
1 2091
On 2008-09-28 01:32, sh***********@g mail.com wrote:
Currently the author of the 'example' script has the following
code embedded within the HTML:

<form action="/">

<div id='customTimeL abel' class='timeLabe l'></div>

<div align="center">
<input type="hidden" id="customTime " value="Refresh" />
</div>

</div>
<div align="center"> </div>

</form>
Then he should go and validate his code, I'd say...

The kind of question you're asking is not much fun to answer, I'm
afraid. We're supposed to debug somebody else's library, which has been
modified, and now it doesn't work anymore. It would be a lot easier if
you could sort of ask a more contained question.
ajaxCaller.shou ldDebug = false;
I don't know anything about ajaxCaller. Maybe shouldDebug can help?
var timeURL = "cgi-bin/test?h=1";
//var timeURL = "tickercontent. txt";
window.onload = function() {
// $("defaultTime" ).onclick=reque stDefaultTime;
// $("customTime") .onclick=reques tCustomTime;
requestCustomTi me();

interval=setInt erval(requestCu stomTime, 1500);
}

function volup(){

clearInterval(i nterval)
showCustomTime( "Change Source", "");

a="requestCusto mTime();"

setTimeout(a, 3000);
clearTimeout(t)
What's "t"?
interval=setInt erval(requestCu stomTime, 1500)
So, in three seconds, requestCustomeT ime will be called twice? Once from
setTimeout() and once from setInterval(). That might explain the
"erratic" behavior.
- Conrad
Sep 28 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1093
by: erlend.dalen | last post by:
Hi all! I'm a newbie to C# and .NET and I'm playing around in Visual C# 2005 Express Edition. I tried to use the wizards to create a table in SQL 2005 Express Ed. and displaying that data in a grid in a form I created in C#. I have got almost everything correct, except I have two issues. The first one is that I'm not able to store the data I add in my grid to the SQL database. When I close the application and open it again, the data is...
4
7133
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to serialize the data to put the array into the cookie. That part of my code is working just fine and displaying fine. The problem I’m having is when I try to unserialize and display; the data does not appear. If I remove my unserialize command line (see...
0
949
by: Ananya1 | last post by:
I have an xml element definition like this <xs:complexType name="OList" mixed="true"> <xs:sequence> <xs:element name="Child" type="class:OListICollection"/> </xs:sequence> </xs:complexType>
5
1727
by: L C | last post by:
Hello, Could someone point in the correct direction with regards to displaying my data in "nicer" format. I have figured out ( with the tutorials on the web, and the O'Reilly PHP & MySQL book) how to store, retrieve, manipulate, and display my data using PHP. But when I do display, it is the block format. I can't seem to find a tutorial that gets into a "prettier" type of display. Is this a HTML issue?
3
1392
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why is my AJAX page not updated properly when using an HTTP GET request in Internet Explorer? ----------------------------------------------------------------------- Microsoft Internet Explorer caches the results of HTTP GET requests. To ensure that the document is retrieved from the server, you will need to use the POST Method. ...
3
6878
by: amollokhande1 | last post by:
Hi All, I am using Sql server 2005 as a backend for my application. I want to read/write the unicode data using sql query. When I am using insert into UnicodeData values('سي') command and if we view the data using sql query analyser, it shows ??. On the otherhand, when i insert the same unicode data through sql enterprize manager simply copying the data in the actual field, it properly stores the data.
1
16948
by: progvar | last post by:
Hi i want to update data in database using datagridview actually i am displaying the data in datagridview and after that i want to update some rows data directly modifying the displayed data into the datagridview how can be done like this please send me some code or some help regards varinder sharma
0
8236
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8173
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8621
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8475
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.