[Javascript] Background script

Peter Lauri lists at dwsasia.com
Mon Aug 28 23:22:08 CDT 2006


Yes, it was that simple. But I needed to create a unique http variable for
this, my original http was used in the rest of the script, and they could
not share connection.


var http2 = getXMLHTTP();

function checkAlerts() {
	geturl = "messageajax.php?action=alertunreadmsg";

	http2.open('get', geturl);
	http2.onreadystatechange = ajaxCheckAlertsHandle;
	http2.send(null);		
}

function ajaxCheckAlertsHandle() {
	if(http2.readyState == 4) {
		document.getElementById("alertbox").innerHTML =
http2.responseText;
		setTimeout(checkAlerts, 30000);
	} else {
		document.getElementById("alertbox").innerHTML = "<p>Checking
inbox...</p>";
	}		
}


/Peter

-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Flávio Gomes
Sent: Tuesday, August 29, 2006 1:43 AM
To: [JavaScript List]
Subject: Re: [Javascript] Background script

/> Is it as simple as just setting a timer function that triggers my 
function?
>  Or is it any drawbacks with doing that? Is other scripts available 
during this time?

/Never played with AJAX, but I believe that "Yes, it's just that simple".

Try it and tell us.

Peter Lauri escreveu:

> Best group members,
>
>  
>
> I have a site where I have an internal message system. With this I 
> want to add functionality so that when a user have a new message, an 
> alert box will show up with that information.
>
>  
>
> What the script actually would do is to every minute connect execute a 
> script that use AJAX to retrieve the number of unread messages, and 
> then alert if it is more then the last time.
>
>  
>
> I want to have a script that does not effect other scripts on the site.
>
>  
>
> Is it as simple as just setting a timer function that triggers my 
> function? Or is it any drawbacks with doing that? Is other scripts 
> available during this time?
>
>  
>
> Best regards,
>
> Peter Lauri
>
>  
>
>  
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>

-- 
Flavio Gomes
flavio at economisa.com.br

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list