Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Ajax onreadystatechange Event

 
Sijesh Alayaril
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Here i'm posting one ajax doubt. Can anyone Please help me to find the solution?

Bellow i'm mentioning the code,

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function loadValues() {
var xmlhttp;
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXobject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function() {
if(xmlhttp.readystate==4 && xmlhttp.status==200){
document.getElementById("mydiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","sijesh",true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="mydiv"><h2>Let AJAX change this text</h2></div>
<button id="button_id" onclick="loadValues()"> Change Content </button>

</body>
</html>


Here I'm when executing this program ,i'm getting xmlhttp.readystate=NaN and xmlhttp.status=0 .Can anyone help me possible way to fix the issuse?

Thanks in Advance,

Best Regards,
Sijesh
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also edit your post to UseCodeTags and be sure to use proper formatting.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this post for causes: http://www.coderanch.com/t/517225/HTML-CSS-JavaScript/ajax-status-code#2341566

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic