CALLER

function showContent(s,i){
	// loading
	//loading_img(1);
	//s = s.toString();
	
	// i undefined
	if(i==undefined){
		i="";
	}
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			//alert('s'+s);
			document.getElementById('s'+s).innerHTML=xmlhttp.responseText;
			
			if(s==0||s==1||s==4||s==7||s==8||s==9){
				var v="js"+s;
				if(document.getElementById(v)){
					eval(document.getElementById(v).innerHTML); // THIS IS THE LINE WITH ERROR
				}else{
					alert('e')
				}
			}
			
			// open next one
			if(s<aS.length-1){
				showContent(s+1);
			}else{
				// render #anchors
				Scroller.init();
				
				// get final doc height
				doc_h = getDocHeight();
			}
			
			// adjust layout
			adjustLayout();
			
			// loading animation
			// OFF
			aS[s][0] = 1;
			
			
			//align();
		}
	}
	
	xmlhttp.open("GET",s+".asp?i="+i,true);
	xmlhttp.send();
}

CODE BEING LOADED:

<script language="javascript" id="js0">
<!--

// vars
oGaleriaSsImage = new Image();
lGaleriaSs = 1;
iGaleriaSs = null;
bGaleriaSs = null;

aGaleriaSs = new Array();
<%
	' Randomizer
	Dim max,min
	Dim aImgs()
	max=4
	min=0

	Set AA = CX.Execute(" Select imagem from 11_arquivos order by ordem DESC")
	c=0
	do while not AA.EoF
		ReDim Preserve aImgs(c+1)
		aImgs(c) = AA.Fields(0)
		AA.MoveNext
		c=c+1
	Loop
	
	max=UBound(aImgs)-1
	
	c=0
	do while c<5
		Randomize
		r = Cstr(Int((max-min+1)*Rnd+min))

		img = aImgs(r)
		
		if c=0 then
			imagem = img
		end if
%>
// Array imgs
aGaleriaSs[<%=c%>] = '<%=img%>';
<%		
		c=c+1
	Loop
	
%>

//nextImgSs('GaleriaSs',0,'ss');

//-->
</script>

I'm getting syntax error on that line there. But it all works fine on Chrome & FF.

Could somebody help me, please?

Member Avatar for stbuchok

You are using eval(), which means it is trying to execute code that is being placed in it as a string. Therefor, what is the value of document.getElementById(v).innerHTML

i changed this part to

v = document.getElementById(v).innerHTML;
eval(v);

but stil get the syntax error on eval.

Member Avatar for stbuchok

Again, what is the value of document.getElementById(v).innerHTML

<!--



// vars

oGaleriaSsImage = new Image();

lGaleriaSs = 1;

iGaleriaSs = null;

bGaleriaSs = null;



aGaleriaSs = new Array();



// Array imgs

aGaleriaSs[0] = '1328723677DSC08869_OK.jpg';



// Array imgs

aGaleriaSs[1] = '1328723663DSC08855_OK.jpg';



// Array imgs

aGaleriaSs[2] = '1328726800DSC00303_OK.jpg';



// Array imgs

aGaleriaSs[3] = '1328723589DSC08841_OK.jpg';



// Array imgs

aGaleriaSs[4] = '1328723663DSC08855_OK.jpg';





//nextImgSs('GaleriaSs',0,'ss');



//-->

What is the value of the v pointer?
Try alert(document.getElementById(v)) before your if conditional and see whats being returned first.

var v="js"+s;

so, v="js0"

good, now see what's being returned by:alert(document.getElementById(v))

Member Avatar for stbuchok

OK, I'm going to try to make this as easy as I can. Above this line:

eval(document.getElementById(v).innerHTML);

put the following code:

alert(document.getElementById(v).innerHTML);

Then run your app again and tell us what the value is.


Please, follow these instructions, if you don't we can't help you.

AGAIN, THIS IS WHAT YOU GET FROM document.getElementById(v).innerHTML:

<!--

// vars

oGaleriaSsImage = new Image();

lGaleriaSs = 1;

iGaleriaSs = null;

bGaleriaSs = null;

aGaleriaSs = new Array();

// Array imgs

aGaleriaSs[0] = '1328723677DSC08869_OK.jpg';

// Array imgs

aGaleriaSs[1] = '1328723663DSC08855_OK.jpg';

// Array imgs

aGaleriaSs[2] = '1328726800DSC00303_OK.jpg';

// Array imgs

aGaleriaSs[3] = '1328723589DSC08841_OK.jpg';

// Array imgs

aGaleriaSs[4] = '1328723663DSC08855_OK.jpg';

//nextImgSs('GaleriaSs',0,'ss');

//-->

Member Avatar for stbuchok

Next time, please indicate that what you have typed is the output, don't just show the code.

Declare variables with var, otherwise they get created as global variables.

Also, it looks like you are only using one variable in that code aGaleriaSs.

I'd re-write it to:

var aGaleriaSs = [];

// Array imgs
aGaleriaSs.push('1328723677DSC08869_OK.jpg');

// Array imgs
aGaleriaSs.push('1328723663DSC08855_OK.jpg');

// Array imgs
aGaleriaSs.push('1328726800DSC00303_OK.jpg');

// Array imgs
aGaleriaSs.push('1328723589DSC08841_OK.jpg');

// Array imgs
aGaleriaSs.push('1328723663DSC08855_OK.jpg');

Still, don't see anything that would cause an error.

I'd also suggest using JSON in order to do this properly.

Ok, thanks. But it still gives me error. The code from the DIV alone is functioning, but when evaluated isn't.

the errror was on the comments <!-- //-->!!! aaaaaaaaaaaaaahhhhhhhhhhhhhhggggg

thanks, anyway!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.