wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Problem with Ajax onreadystatechange Event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem with Ajax onreadystatechange Event" Watch "Problem with Ajax onreadystatechange Event" New topic
Author

Problem with Ajax onreadystatechange Event

Sijesh Alayaril
Ranch Hand

Joined: Jan 13, 2012
Posts: 37
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

Joined: Mar 07, 2010
Posts: 1632
    
    7

Also edit your post to UseCodeTags and be sure to use proper formatting.


[How To Ask Questions][Read before you PM me]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
See this post for causes: http://www.coderanch.com/t/517225/HTML-CSS-JavaScript/ajax-status-code#2341566

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Ajax onreadystatechange Event
 
Similar Threads
A problem in hiding a button
Simple AJAX query what I'm missing?
JSF1.2 Core+AJAX+Portlets getting problematic while constructing the url
502 Bad Gateway error during process
Trying to use AJAX to call a servlet