CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    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
  •  





Click Here to Expand Forum to Full Width

Featured