I have this set of functions and it refuses to run
alert('Ok I reach in if 1')
or
alert('Ok I reach in if 2')
despite that I have no html or javascript errors.
alert(res[3]) before if output 'baza'
alert(typeof res[3]) before if output 'string'
function ataseazaPoza(id, poza) {
tip = '';
if (id.search("dragzonesortpic") == 0) {
tip = 'sort';
} else {
tip = 'baza';
}
http.open('get', 'produse_ataseazaPoza.php?id=' + id + '&image=' + poza + '&tip=' + tip + '&nocache=' + Math.random());
http.onreadystatechange = ataseazaPozaReply;
http.send(null);
}
function ataseazaPozaReply() {
if (http.readyState == 4) {
var response = http.responseText;
res = response.split(";");
if (res[0] == 'er') {
alert('Eroare: ' + res[1] + ' ' + res[2]);
} else {
keys = res[2].split("-");
alert(res[3]);
if (res[3] == 'baza') {
alert('Ok I reach in if 1');
elemRo = document.getElementById('rowuv' + res[1]).style.backgroundColor = 'transparent';
elemOv = document.getElementById('dragzoneuv' + res[1]);
imgurl = "url('../prod_imagini/" + keys[0] + "/" + keys[0] + "/" + res[2] + "')";
elemOv.style.backgroundImage = imgurl;
}
if (res[3] == 'sort') {
alert('Ok I reach in if 2');
randPlus = parseInt(res[1]) + 1;
elemRo = document.getElementById('sortHoverDrop' + res[1]).style.backgroundColor = 'transparent';
elemOv = document.getElementById('dragzonesortpic' + res[1]);
imgurl = "url('../prod_imagini/" + keys[0] + "/" + keys[0] + "/" + res[2] + "')";
document.getElementById('pozaHiddenSort' + res[1]).value = imgurl;
elemOv.style.backgroundImage = imgurl;
}
}
}
}
Why it not enter if?real code
Aucun commentaire:
Enregistrer un commentaire