JS and Jquery problem
- by Sonny
hi i got the problem the script.js gives me
<div id="gracze">
<div id="10" class="char" style="z-index: 19; top: 592px; left: 608px; "></div>
<div id="14" class="char" style="z-index: 25; top: 784px; left: 608px; "></div>
</div>
instead
<div id="gracze">
<div id="4" class="char" ... ></div>
<div id="10" class="char" style="z-index: 19; top: 592px; left: 608px; "></div>
<div id="14" class="char" style="z-index: 25; top: 784px; left: 608px; "></div>
</div>
get_players.php
4/62/6
10/19/19
14/19/25
script.js
function get_players()
{
$.ajax({
type: "POST",
url: "get_players.php",
dataType: "html",
success: function(data) {
var str = data;
var chars = str.split("<br />");
var lol = chars.length;
for(var i = lol; i--; ) {
chars[i] = chars[i].split('/');
var o = document.getElementById(chars[i][0]);
var aimt = i;
if (!o) {
if (aimt!=chars.length-1 && aimt != 0) {
$('#gracze').html('<div id="'+chars[aimt][0]+'" class="char"></div>'+$('#gracze').html());
$('#'+chars[aimt][0]).css("top", chars[aimt][2]*32-16+"px");
$('#'+chars[aimt][0]).css("left", chars[aimt][1]*32+"px");
$('#'+chars[aimt][0]).css("z-index", chars[aimt][1]*32);
}
} else {
$('#'+chars[aimt][0]).animate({
"top": chars[aimt][2]*32-16+"px", "left": chars[aimt][1]*32+"px"
}, { duration: 275});
//$('#'+chars[aimt][0]).css("top", chars[aimt][1]*32-16+"px");
//$('#'+chars[aimt][0]).css("left", chars[aimt][2]*32+"px");
$('#'+chars[aimt][0]).css("z-index", chars[aimt][2]);
}
}
}});
setTimeout("get_players();", 1000);
}
I think it's because of for(var i = lol; i--; ) {