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

Thread: onreadystatechange do nothing

  1. #1
    Join Date
    May 2005

    onreadystatechange do nothing

    i wrote-
    function updateEventItems(value)
    { var xmlObj=null;

    if (window.XMLHttpRequest)
    xmlObj=new XMLHttpRequest();
    else if (window.ActiveXObject)
    xmlObj=new ActiveXObject("Microsoft.XMLHTTP");
    else return;

    { if(xmlObj.readyState==4) alert("ok");

    and in some component i have added-

    i guess im missing something because im not getting the "ok" alert
    what is wrong ?
    thanks in advanced.

  2. #2
    Join Date
    Sep 2006

    Re: onreadystatechange do nothing

    Because you are saying when the file is ready then do whatever is inside that function. If you are not sending anything to the file, then you wont get the alert box. Create an empty file, and then add the following lines to the end:
    Code: ("POST", "./file.ext", true);
    xmlObj.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
    xmlObj.send (null);
    then you should get the alert box, because javascript went to the page, did something (in this case just returned an empty file), and it came back successfully, so you should get the alert box.

    And one other thing, your xmlObj should be this:
    var xmlObj = (window.ActiveXObject) ? new ActiveXObject ("Microsoft.XMLHttp") : new XMLHttpRequest();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)