• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Ajax onreadystatechange Event

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also edit your post to UseCodeTags and be sure to use proper formatting.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this post for causes: https://coderanch.com/t/517225/HTML-CSS-JavaScript/ajax-status-code#2341566

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic