hi ok i have a problem im abit of noob but im trying to get this working
whats ment to happen is all three classnames should change but they dont, i tried this code thinking the for loop would go through 1-130 checking the .onreadystatechange but firefox error console gives me this error
btw there isnt 3 div tags like this ive just cut them it changes depending on page so i need a fix that will work from 1-130
Error: AjaxResponseArray[i] is undefined
Source File: [url]http://127.0.0.1/lib/js/trophies.js?v=1244586482
Line: 42
but it shouldnt get to line 42 because i have a if function testing if undefined, im working with Firefox 3.0.0.10
Thanks in Advance
HTML onclick code if i click these one after another they all do there job but only the last one has its classNames changed
[code=html]<a href=”http://127.0.0.1/page/trophies/update.php?c=e4da3b7fbbce2345d7772b0674a318d5&gid=68&tid=2304&refer=http%3A%2F%2F127.0.0.1%2Fpage%2Ftrophies%2Fadd.php%3Fuid%3D5%26gid%3D68%26c%3De4da3b7fbbce2345d7772b0674a318d5″ onClick=”update_trophy(‘2304′,’68’, ‘e4da3b7fbbce2345d7772b0674a318d5’);return false;”>
<div id=”div2304″ class=”trophy-got” title=”Score at least 10 goals in one game.” alt=”Score at least 10 goals in one game.”>
<div id=”divimage2304″ class=”image-got”>
<img src=”http://127.0.0.1/lib/images/trophies/68/2304.png?v=1240083230″ title=”Score at least 10 goals in one game.” name=”stopload” alt=”Score at least 10 goals in one game.” id=”image2304″/>
</div>
<div class=”text-got”>
<h3 id=”h32304″>Score Big</h3>
<h4 id=”h42304″>Score at least 10 goals in one game.</h4>
</div>
<div class=”type-got”>
<img src=”http://127.0.0.1/lib/images/tick.gif” id=”type2304″ style=”width:16px;height:16px;margin:4px”/>
</div>
</div>
</a>
<a href=”http://127.0.0.1/page/trophies/update.php?c=e4da3b7fbbce2345d7772b0674a318d5&gid=68&tid=2305&refer=http%3A%2F%2F127.0.0.1%2Fpage%2Ftrophies%2Fadd.php%3Fuid%3D5%26gid%3D68%26c%3De4da3b7fbbce2345d7772b0674a318d5″ onClick=”update_trophy(‘2305′,’68’, ‘e4da3b7fbbce2345d7772b0674a318d5’);return false;”>
<div id=”div2305″ class=”trophy-got” title=”Score two goals with a Big Player powerup in one game.” alt=”Score two goals with a Big Player powerup in one game.”>
<div id=”divimage2305″ class=”image-got”>
<img src=”http://127.0.0.1/lib/images/trophies/68/2305.png?v=1240083230″ title=”Score two goals with a Big Player powerup in one game.” name=”stopload” alt=”Score two goals with a Big Player powerup in one game.” id=”image2305″/>
</div>
<div class=”text-got”>
<h3 id=”h32305″>Big Player</h3>
<h4 id=”h42305″>Score two goals with a Big Player powerup in one game.</h4>
</div>
<div class=”type-got”>
<img src=”http://127.0.0.1/lib/images/tick.gif” id=”type2305″ style=”width:16px;height:16px;margin:4px”/>
</div>
</div>
</a>
<a href=”http://127.0.0.1/page/trophies/update.php?c=e4da3b7fbbce2345d7772b0674a318d5&gid=68&tid=2306&refer=http%3A%2F%2F127.0.0.1%2Fpage%2Ftrophies%2Fadd.php%3Fuid%3D5%26gid%3D68%26c%3De4da3b7fbbce2345d7772b0674a318d5″ onClick=”update_trophy(‘2306′,’68’, ‘e4da3b7fbbce2345d7772b0674a318d5’);return false;”>
<div id=”div2306″ class=”trophy-got” title=”Score two goals with a Super Speed powerup in one game.” alt=”Score two goals with a Super Speed powerup in one game.”>
<div id=”divimage2306″ class=”image-got”>
<img src=”http://127.0.0.1/lib/images/trophies/68/2306.png?v=1240083230″ title=”Score two goals with a Super Speed powerup in one game.” name=”stopload” alt=”Score two goals with a Super Speed powerup in one game.” id=”image2306″/>
</div>
<div class=”text-got”>
<h3 id=”h32306″>Super Speed</h3>
<h4 id=”h42306″>Score two goals with a Super Speed powerup in one game.</h4>
</div>
<div class=”type-got”>
<img src=”http://127.0.0.1/lib/images/tick.gif” id=”type2306″ style=”width:16px;height:16px;margin:4px”/>
</div>
</div>
</a>
AJAX CODE
[code=html]
var AjaxResponseArray = new Array()
var AjaxUrlArray = new Array()
var AjaxTidArray = new Array()
var AjaxGidArray = new Array()
var index=0;
function update_trophy(tid, gid, code){
index++;
// We got one
try{
AjaxResponseArray[index] = new XMLHttpRequest();
}
catch(e){
try{
AjaxResponseArray[index] = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e2){
try{
AjaxResponseArray[index] = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e){
// no AJAX support
}
}
}
AjaxUrlArray[index]=site_url+”page/trophies/update.php?gid=”+gid+”&tid=”+tid+”&c=”+code+”&refer=”+site_url+”&aj=1″
AjaxUrlArray[index]=AjaxUrlArray[index]+”&sid=”+Math.random()
AjaxTidArray[index]=tid
AjaxGidArray[index]=gid
AjaxResponseArray[index].open(“GET”,AjaxUrlArray[index],true)
for (i=0;i<=130;i++){
if (AjaxResponseArray[i] != null || AjaxResponseArray[i] != undefined){
AjaxResponseArray[i].onreadystatechange = CheckResponse;
}
}
AjaxResponseArray[index].send(null)
}
function CheckResponse(){
AjaxResponseArray[i].onreadystatechange = function() {
if(AjaxResponseArray[i].readyState == 4 || AjaxResponseArray[i].readyState == “complete”){
document.getElementById(“dump”).innerHTML=AjaxResponseArray[i].responseText+” index: “+index;
document.getElementById(“image”+AjaxTidArray[i]).src=site_url+”lib/images/trophies/”+AjaxGidArray[i]+”/”+AjaxTidArray[i]+”.png”;
if(AjaxResponseArray[i].responseText == “Removed”){
//if not got
document.getElementById(“div”+AjaxTidArray[i]).className=”trophy”;
document.getElementById(“divimage”+AjaxTidArray[i]).className=”image”;
document.getElementById(“h4″+AjaxTidArray[i]).style.display=”block”;
document.getElementById(“type”+AjaxTidArray[i]).style.display=”none”;
}else{
//if got
document.getElementById(“div”+AjaxTidArray[i]).className=”trophy-got”;
document.getElementById(“divimage”+AjaxTidArray[i]).className=”image-got”;
document.getElementById(“h4″+AjaxTidArray[i]).style.display=”none”;
document.getElementById(“type”+AjaxTidArray[i]).style.display=”none”;
}
}else{
//document.getElementById(“loading”).style.display=”block”;
document.getElementById(“dump”).innerHTML=”Loading…”+” index: “+index;
document.getElementById(“image”+AjaxTidArray[i]).src=site_url+”lib/images/loading.gif”;
}
}
}