navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

redisplay sql data without refresh

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> redisplay sql data without refresh
Page: [1]
 
octavious

 

Posts: 68
Joined: 2/10/2005
From: Northern California
Status: offline

 
redisplay sql data without refresh - 7/27/2008 12:57:28   
Hi, does anyone have a simple code (asp or java) to redisplay a sql select data without having to refresh the page? Im building my own IM or chat window within a site and this is the only function I'm missing. Right now, the page refreshes every 5 seconds which can be annoying if the person has the clicking sound turned on for open new page.

Im using asp pages to retrieve data from a SQL database. Any help/replies would be greatly appreciated.

Octavious
TexasWebDevelopers

 

Posts: 202
Joined: 2/22/2002
From:
Status: offline

 
RE: redisplay sql data without refresh - 7/30/2008 13:32:31   
This sounds like a great opportunity to use AJAX.
Take a look at a little chat app called "sbox" written in ASP/AJAX to see a nice working example. I think the blog site is genusproject.com on the download link...free.

(in reply to octavious)
octavious

 

Posts: 68
Joined: 2/10/2005
From: Northern California
Status: offline

 
RE: redisplay sql data without refresh - 8/2/2008 18:53:02   
Thanks. but not exactly what I'm looking for. I really dont want to integrate any outside application. I'll continue to tweak with this and see what I can come up and will post.

(in reply to TexasWebDevelopers)
TexasWebDevelopers

 

Posts: 202
Joined: 2/22/2002
From:
Status: offline

 
RE: redisplay sql data without refresh - 8/2/2008 22:37:33   
I wasn't suggestiing you integrate that app--I was suggesting you look at the way AJAX was being used to refresh the database call without refreshing the whole page--it's what you want.

(in reply to octavious)
pd_it_guy

 

Posts: 191
Joined: 3/4/2008
Status: offline

 
RE: redisplay sql data without refresh - 8/3/2008 20:17:16   
I don't suggest re-inventing what someone has already done, and is giving away for free... but... if the AJAX product that TWD refers to for whatever reason is not adaptable or won't work for you, could you not just place your query to refresh whatever needs to be refreshed in a Do Until (something, as yet to be determined, stops it)/ loop set to cycle at whatever time interval you want. The delay code is pretty straightforward. I have not however tested it yet in an application like yours.

I don't thing you need to refresh an entire page, just to refresh the section containing the query. This would of course have to be a slimmed-down essentialized query to be managable.

Does that sound like something that would work for you and solve the problem.

(in reply to TexasWebDevelopers)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: redisplay sql data without refresh - 8/15/2008 11:05:11   
Hey guys, that's what AJAX is. That's what Texas was saying.

And without some kind of AJAX, you will need to refresh the whole page. You're forgetting that HTML is state-less and without some kind of client-side script (JavaScript) re-writing sections of the page on-the-fly, you *will* need to refresh the page.

Even the .NET code and classes use AJAX; it just isolates you from the code.

</$.02>

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to pd_it_guy)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: redisplay sql data without refresh - 8/15/2008 12:44:09   
...and it's really not that difficult. Sounds scary, I know but it's really not that bad. Here's what you do for a test:

1. Build a very basic page with the query results you want showing on it. we can worry about specifying queries later. I suggest making a file called "test.asp" and putting it in a folder called "includes".

2. Build another page (an .asp, .htm, or whatever) and use the following code on it:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>AJAX test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
var xmlHttp;
 
function getDiscussion(str)
{
    var url="/includes/test.asp";
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
}
 
function stateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("myAJAXdiv").innerHTML=xmlHttp.responseText;
    }
}
 
function GetXmlHttpObject(handler)
{
    var objXmlHttp=null
 
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("Opera not supported...")
        return;
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        }
        try
        {
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        }
        catch(e)
        {
            alert("Error. Scripting for ActiveX might be disabled")
            return
        }
    }
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler
        return objXmlHttp
    }
} 

function startWatching()
{
 getDiscussion(this.value);
 setTimeout("startWatching()",5000);
}
</script>
</head>

<body onLoad="startWatching();">
	<div style="margin: 10px;" id="myAJAXdiv"></div>
</body>
</html>


Save the page and browse to it. If the line:

var url="/includes/test.asp";

is to the correct path and file and there are no errors on test.asp, you should see the results updated every 5 seconds in the DIV "myAJAXdiv". And you can change the 5 second thing right here:

setTimeout("startWatching()",5000);

where the 5000 is milliseconds.

See, it's really not that bad. :) Hope it helps.



_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to rdouglass)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> redisplay sql data without refresh
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts