File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem with Ajax onreadystatechange Event" Watch "Problem with Ajax onreadystatechange Event" New topic

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>
<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){
<div id="mydiv"><h2>Let AJAX change this text</h2></div>
<button id="button_id" onclick="loadValues()"> Change Content </button>


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,
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

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

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

Joined: Nov 08, 2001
Posts: 15385
See this post for causes:

I agree. Here's the link:
subject: Problem with Ajax onreadystatechange Event
It's not a secret anymore!