V
Vishalika
Guest
Hi,
I have written following code in ajax.
This is a javascript function called on onchange event of a button.
This code works fine in firefox and chrome but does not work in IE8.0+
the values don't get displayed.
plz suggest me if there is any change.
thnx in advance.
<script type="text/javascript">
function showUser(str) {
if (str=="") {
document.getElementById("userDetailsShownHere").innerHTML="";
return;
}
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) {
document.getElementById("userDetailsShownHere").innerHTML=xmlhttp.responseText;
document.getElementById("btn").name=str;
showGift(str);
}
}
xmlhttp.open("GET","getuser.php?username="+str,true);
xmlhttp.send();
}
//This code will execute on button click
function showGift(str) {
var life = document.getElementById("lifeLabel").value;
var number = parseInt(life, 0);
if(number == 55){
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) {
document.getElementById("userDetailsShownHere").innerHTML=xmlhttp.responseText;
document.getElementById("btn").name=str;
document.getElementById("btn").style.display="inline";
}
}
xmlhttp.open("GET","getuser.php?username="+str,true);
xmlhttp.send();
}
else if(number > 0){
document.getElementById("noLife").style.display="none";
number = number - 1;
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) {
document.getElementById("userDetailsShownHere").innerHTML=xmlhttp.responseText;
document.getElementById("btn").name=str;
document.getElementById("btn").style.display="none";
if(document.getElementById("cometomorrow") || document.getElementById("win")){
document.getElementById("btn").style.display="none";
console.log("hide");
}else{
setTimeout("showButton()", 1000);
}
}
}
xmlhttp.open("GET","getgift.php?username="+str+"&loop="+number,true);
xmlhttp.send();
}
else {
document.getElementById("userDetailsShownHere").innerHTML="";
document.getElementById("noLife").style.display="inline";
document.getElementById("btn").style.display="none";
}
}
</script>
Continue reading...
I have written following code in ajax.
This is a javascript function called on onchange event of a button.
This code works fine in firefox and chrome but does not work in IE8.0+
the values don't get displayed.
plz suggest me if there is any change.
thnx in advance.
<script type="text/javascript">
function showUser(str) {
if (str=="") {
document.getElementById("userDetailsShownHere").innerHTML="";
return;
}
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) {
document.getElementById("userDetailsShownHere").innerHTML=xmlhttp.responseText;
document.getElementById("btn").name=str;
showGift(str);
}
}
xmlhttp.open("GET","getuser.php?username="+str,true);
xmlhttp.send();
}
//This code will execute on button click
function showGift(str) {
var life = document.getElementById("lifeLabel").value;
var number = parseInt(life, 0);
if(number == 55){
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) {
document.getElementById("userDetailsShownHere").innerHTML=xmlhttp.responseText;
document.getElementById("btn").name=str;
document.getElementById("btn").style.display="inline";
}
}
xmlhttp.open("GET","getuser.php?username="+str,true);
xmlhttp.send();
}
else if(number > 0){
document.getElementById("noLife").style.display="none";
number = number - 1;
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) {
document.getElementById("userDetailsShownHere").innerHTML=xmlhttp.responseText;
document.getElementById("btn").name=str;
document.getElementById("btn").style.display="none";
if(document.getElementById("cometomorrow") || document.getElementById("win")){
document.getElementById("btn").style.display="none";
console.log("hide");
}else{
setTimeout("showButton()", 1000);
}
}
}
xmlhttp.open("GET","getgift.php?username="+str+"&loop="+number,true);
xmlhttp.send();
}
else {
document.getElementById("userDetailsShownHere").innerHTML="";
document.getElementById("noLife").style.display="inline";
document.getElementById("btn").style.display="none";
}
}
</script>
Continue reading...