-
March 26th, 2009, 04:23 AM
#1
AJAX readyState = undefined
Hello Codegurus,
The following piece of code returns a readystate that's "undefined".
The alert appears 4 times in IE and in FF. so i reckon the readystate changes 4 times ?; but it's always "undefined".
Could someone tell me what i'm doing wrong?, Thanks.
EDIT: Sorry, just noticed the AJAX forum. feel free to move this topic.
Code:
function xmlHttpRequest(){
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("XMLHTTP not supported.");
return null;
}
}
function ajaxFunction(){
var xhr = xmlHttpRequest();
xhr.onreadystatechange = function(){
alert(this.readystate);
}
xhr.open("GET","url",true);
xhr.send(null);
}
Last edited by TimothyH; March 26th, 2009 at 04:29 AM.
Reason: Wrong category
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|