After making a AJAX request from .js file the readystate propertyof the Http object is not changing

Discussion in 'ASP .Net' started by Mathan Babu, Sep 19, 2006.

  1. Mathan Babu

    Mathan Babu Guest

    Hello,

    Once the AJAX request is fired the readystate property remain as 1. It
    never gets changed and the callback method is not firing as a result the
    ..aspx page is not being rendered.

    The two functions that is involved in the above mentioned issues are
    placed below:

    fn #1

    function ajax_SendRequest(fullUrl, callback)
    {
    var xmlHttp = CreateXmlHttpObject();

    var url = fullUrl.split('?')[0];
    var params = fullUrl.split('?')[1];

    //Use post method in case data send to server exceed limit.
    xmlHttp.open("POST", url, /* async = */ true);
    xmlHttp.onreadystatechange = function() {
    _ajax_HandleResponse(xmlHttp, callback); setCursorToArrow();}

    xmlHttp.setRequestHeader("Content-type",
    "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    if (currentXmlHttp != null)
    {
    pendingRequests.push(xmlHttp);
    pendingRequestsContent.push(params);
    }
    else
    {
    currentXmlHttp = xmlHttp;
    xmlHttp.send(params);
    }
    }

    fn #2

    function _ajax_HandleResponse(xmlHttp, callback)
    {

    if (xmlHttp.readyState != 4)
    {
    // Not finished yet; do nothing
    }
    else if (xmlHttp.status != 200)
    {
    if( xmlHttp.status != 0 ) // Not aborted
    {
    _ajax_ReportError("AJAX request failed with HTTP code " +
    xmlHttp.status + " : " + xmlHttp.statusText);
    }
    }
    else
    {
    var dom = xmlHttp.responseXml;
    var err = dom.parseError;

    if (err.errorCode != 0)
    {
    _ajax_ReportError(err.reason + "\nXML context: " +
    _ajax_FocusSubString(err.srcText, err.linepos));
    }
    else
    {
    var root = xmlHttp.responseXML.selectSingleNode("root");

    if (! root)
    {
    _ajax_ReportError("XML was valid but did not have the expected
    'root' document element");
    }
    else
    {
    _ajax_UnpackResponse(root);
    if(root.selectSingleNode('content') &&
    root.selectSingleNode('content').attributes.getNamedItem('ErrorCode'))
    callback = null;

    if (callback)
    {
    callback(root);
    }

    var fn = document.body.onresize; // Yes, we have to alias this.
    No, we don't know why.
    if (fn) fn();
    }
    }
    }
    if (pendingRequests.length > 0)
    {
    currentXmlHttp = pendingRequests.shift();
    currentXmlHttp.send(pendingRequestsContent.shift());
    }
    else
    {
    currentXmlHttp = null;
    }
    }


    Thanks,
    Mathan.
     
    Mathan Babu, Sep 19, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael J Whitmore

    img readyState problem

    Michael J Whitmore, Oct 29, 2003, in forum: Javascript
    Replies:
    1
    Views:
    235
    Lasse Reichstein Nielsen
    Oct 29, 2003
  2. Eric Wallstedt
    Replies:
    9
    Views:
    280
    Eric W
    Feb 23, 2006
  3. cypress phill

    Ajax sometimes stops at readystate 1

    cypress phill, Jul 11, 2006, in forum: Javascript
    Replies:
    0
    Views:
    106
    cypress phill
    Jul 11, 2006
  4. gp

    ajax readyState 1 wall

    gp, Oct 12, 2006, in forum: Javascript
    Replies:
    2
    Views:
    173
    Michael Winter
    Oct 12, 2006
  5. Mark Knochen

    AJAX - resObjekt.readyState is only 1

    Mark Knochen, Nov 19, 2006, in forum: Javascript
    Replies:
    2
    Views:
    169
    Richard Cornford
    Nov 20, 2006
Loading...

Share This Page