User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 422,663 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,654 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 906 | Replies: 3
Reply
Join Date: Jun 2007
Posts: 71
Reputation: Pro2000 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pro2000's Avatar
Pro2000 Pro2000 is offline Offline
Junior Poster in Training

Question Ajax selecting from MySQL

  #1  
Dec 13th, 2007
Hello everybody,
I wrote a file using AJAX this is the code I wrote:
File.js
var http = createRequestObject();
function createRequestObject(){
    var request_;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        request_ = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        request_ = new XMLHttpRequest();
    }
    return request_;
}
function getInfo(){
    http.open('get', 'GtCht.php');
    http.onreadystatechange = handleInfo;
    http.send(null);
}
function handleInfo(){
    if(http.readyState == 4){
        var response = http.responseText;
        document.getElementById('ChtPlc').innerHTML= document.getElementById('ChtPlc').innerHTML + response;
    }
}
I binded that file with a function in javascript:
<script language="javascript">
function GetINF(){
window.setTimeout(getInfo(),1000)
}
</script>
So when this file selects an animated image from the MySQL database it refreshes the image automaticially each 1 second, however I want this image to stay moving until its final frame.
Could you help please?
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 75
Reputation: hielo is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
hielo hielo is offline Offline
Junior Poster in Training

Re: Ajax selecting from MySQL

  #2  
Dec 13th, 2007
My comments are in the code:
var frame=0;
var interval=null;
var http = createRequestObject();
function createRequestObject(){
    var request_=null;

    //not necessary
    //var browser = navigator.appName;
	if(window.XMLHttpRequest)
	{
	request_ = new XMLHttpRequest();
	}
    else if(window.ActiveXObject){
        request_ = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return request_;
}
function getInfo(){
	if( http )
	{
		//first parameter MUST BE UPPERCASE
		http.open('GET', 'GtCht.php');
		http.onreadystatechange = handleInfo;
		http.send(null);
		++frame;
		if(frame < 24 )
		{
			clearInterval(interval);
		}
    }
    else
    {
    	alert("Your browser does not support AJAX.");
    }
}
function handleInfo(){
	//must make sure you optained the resource successfully
    if(http.readyState == 4 && http.status==200){
        var response = http.responseText;
        document.getElementById('ChtPlc').innerHTML= document.getElementById('ChtPlc').innerHTML + response;
    }
}

function GetINF(){
 interval = setInterval(getInfo(),1000)
}
Reply With Quote  
Join Date: Jun 2007
Posts: 71
Reputation: Pro2000 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pro2000's Avatar
Pro2000 Pro2000 is offline Offline
Junior Poster in Training

Re: Ajax selecting from MySQL

  #3  
Dec 14th, 2007
Thanks but that does not help...
I want to keep the images (.GIF) moving until it completes.
However my file does not do that...
the page auto-refreshes...
Can you solve it?
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,851
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Ajax selecting from MySQL

  #4  
Dec 14th, 2007
Can you link us to a sample page so we can find out what *exactly* are you trying to do?
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC