Jump to content

[SOLVED] need some help getting an image....


meomike2000

Recommended Posts

i have a script set up that will get some values from a php file.

then there is a delay and then it will get another value from the same php file.

after the cycle gets the last set of values from that file it will reset and start over getting the values again.....

 

the ajax script inserts the value onto my page, then when the next value comes in after the delay it will remove the first value and replace it with the second and so on....

 

how can i get one of the values returned to be an image that is stored on my machine....

o ya, all the scripts are local on my machine..... only on localhost.......

here is the ajax file....

var Folder = new function() {
this.ajax = null;
this.enable = true;
this.folderDiv1 = null;
this.folderDiv2 = null;
this.sponser = 1; 
this.getsponserhand = null;

this.init = function() {
	var self = Folder;
	self.ajax = new Ajax();
	var enable = self.enable; 
	self.folderDiv1 = document.getElementById('folderDiv1');
	self.folderDiv2 = document.getElementById('folderDiv2');
	self.togglefolder(enable);
	self.getsponsers();		
};

this.togglefolder = function(able) {
	var self = Folder;
	if (able) {
		self.folderDiv2.className = 'folderActive';
		self.folderDiv1.className = 'folderDisabled';
		self.folderDiv1.disabled = true;
		self.folderDiv2.onclick = self.getupdates;
	}
	else {
		self.folderDiv2.className = 'folderDisabled';
		self.folderDiv1.className = 'folderActive';
		self.folderDiv2.disabled = true;
		self.folderDiv1.onclick = self.getsponsers;
	}
};

this.getupdates = function() {
	var self = Folder;
	self.stopdelay();
	self.ajax.doGet('/ajaxtest/update.php?sponser=' + self.sponser, self.showfolder2);
	self.enable = false; 
};	

this.getsponsers = function() {
	var self = Folder;
	self.ajax.doGet('/ajaxtest/sponsers.php?sponser=' + self.sponser, self.showfolder1);
	self.enable = true; 
};

this.getsponsersdelay = function() {
	var self = Folder;
	self.getsponserhand = setTimeout(self.getsponsers, 1500);
};	

this.stopdelay = function() {
	var self = Folder;
	clearTimeout(self.getsponserhand);
	if (self.ajax) {
		self.ajax.abort();
	}
};

this.showfolder1 = function(str) {
	var self = Folder;
	var displays = document.getElementById('displays');
	var folder = null;
	if (str==100) {
		self.sponser = 1;
		self.getsponsers();
	}
	else {
		self.sponser = ++self.sponser;
		self.togglefolder(true);
		folder = document.createElement('div');
		folder.className = 'folderDiv1';
		folder.appendChild(document.createTextNode(str));
		if (displays.firstChild) {
			displays.removeChild(displays.firstChild);
		}
		displays.appendChild(folder);
		self.getsponsersdelay();
	}	
};

this.showfolder2 = function(str) {
	var self = Folder;
	var displays = document.getElementById('displays');
	var folder = null;
	self.togglefolder(false);
	folder = document.createElement('div');
	folder.className = 'folderDiv2';
	folder.appendChild(document.createTextNode(str));
	if (displays.firstChild) {
		displays.removeChild(displays.firstChild);
	}
	displays.appendChild(folder);		
};

this.cleanup = function() {
	var self = Folder;
	self.ajax = null;
	self.enable = null;
	self.folderDiv1 = null;
	self.folderDiv2 = null;
	self.sponser = 1;
	self.getsponserhand = null;
};
};

 

and my php file....

<?php
$sponser = $_GET['sponser'];
if($sponser==1) {
header('Content-Type: text/plain');
print "meo2000.net";
}elseif($sponser==2) {
header('Content-Type: text/plain');
print "the cleaning lady";
}elseif($sponser==3) {
//$file = 'sspx0044.jpg';
//$fh = fopen($file, 'r');
//$data = fread($fh, filesize($file));
//fclose($fh);
//$filesize = filesize($file);
//$filetype = filetype($file);
//header("Content-Disposition: attachment; filename=$file");
   //header("Content-length: $filesize");
   //header("Content-type: $filetype");
   header('Content-Type: text/plain');
$data = "this will b an image soon";	
print $data;

}else{
print "100";
}

 

any help would be great....  thanks mike

Link to comment
Share on other sites

dont know if  i did it correct or not but i created the img with inside a div inside the my ajax folder function the just sent back the src of the image and assigned that to the img tag that i created. it works anyhow......

 

self.sponser = ++self.sponser;
			self.togglefolder(true);
			folder = document.createElement('div');
			folder.className = 'folderdiv1';
			add = document.createElement('div');
			add.className = 'folderadd';
			add.appendChild(document.createTextNode(line2));
			add.appendChild(document.createElement('br'));
			add.appendChild(document.createTextNode(line3));
			add.appendChild(document.createElement('br'));
			add.appendChild(document.createTextNode(line4));
			img = document.createElement('img');
			img.src = file; 
			img.className = 'folderimg';
			clearAll = document.createElement('br');
			clearAll.className = 'clearAll';
			folder.appendChild(add);
			folder.appendChild(img);
			folder.appendChild(clearAll);
			if (displays.firstChild) {
				displays.removeChild(displays.firstChild);
			}
			displays.appendChild(folder);
			self.getsponsersdelay();

 

like i said may not be perfectly correct but it works......

 

thanks mike.....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.