• XMLHttpRequest handling in different browsers

    Home » Forums » Developers, developers, developers » Web design and development » XMLHttpRequest handling in different browsers

    • This topic has 3 replies, 2 voices, and was last updated 15 years ago.
    Author
    Topic
    #469665

    I am implementing a 3270 terminal emulator with a special web server and the rendering of the screen in a web browser. The screen layout is contained in XML data which is retrieved by the XMLHttpRequest object. There is always an XMLHttpRequest in effect until data arrives from the mainframe via the server. This data may be unsolicited. When data must be sent to the mainframe via the server, the XMLHttpRequest is canceled by either the browser or the server depending on the browser used. A new request is then issued.

    Here is the problem I have: In both IE8 and FF3 this mechanism is working fine, but in Chrome the subsequent request is simply not sent to the server. Calling the abort() member of the previously canceled request before making a new request does not help. Any help will be appreciated.

    Viewing 0 reply threads
    Author
    Replies
    • #1229581

      In both IE8 and FF3 this mechanism is working fine, but in Chrome the subsequent request is simply not sent to the server. Calling the abort() member of the previously canceled request before making a new request does not help. Any help will be appreciated.

      Does your code set any conditions on issuing the subsequent request? Just wondering whether you’re checking for some value that differs after abort() in different browsers.

      • #1229877

        Does your code set any conditions on issuing the subsequent request? Just wondering whether you’re checking for some value that differs after abort() in different browsers.

        The subsequent request is actually a completely new request. Here is the code:

        Code:
        var xhttp=0;
        
        function XhRequest(name)
        {
         if (xhttp) {  // this code not required for IE/FF; unsuccessful attempt to get Chrome to work
          xhttp.abort();
          delete xhttp;
          xhttp=0;
         }
         if (window.XMLHttpRequest){
          xhttp=new XMLHttpRequest()
         }
         else{
          xhttp=new ActiveXObject("Microsoft.XMLHTTP")
         }
         xhttp.open("POST",name,true);
         xhttp.onreadystatechange=checkXHR;
         xhttp.send(session);
        }
        
        • #1230015

          The subsequent request is actually a completely new request. Here is the code:

          Code:
          var xhttp=0;
          
          function XhRequest(name)
          {
           if (xhttp) {  // this code not required for IE/FF; unsuccessful attempt to get Chrome to work
            xhttp.abort();
            delete xhttp;
            xhttp=0;
           }
           if (window.XMLHttpRequest){
            xhttp=new XMLHttpRequest()
           }
           else{
            xhttp=new ActiveXObject("Microsoft.XMLHTTP")
           }
           xhttp.open("POST",name,true);
           xhttp.onreadystatechange=checkXHR;
           xhttp.send(session);
          }
          

          I found a solution, but I’m not too happy with it; if not a bug, it is a serious shortcoming of Chrome.

          The subsequent request is initiated by setting a timeout in the onreadystatechange handler which will issue the next request after the timeout:

          Code:
          function checkXHR()
          {
           if (xhttp.readyState!=4)
             return;
           // read XML and build screen
           setTimeout("XhRequest('data3270.xml')",400);
          }
          

          With IE and FF I can use a timeout of 50 ms, with Chrome it needs to be 400 ms.

    Viewing 0 reply threads
    Reply To: XMLHttpRequest handling in different browsers

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: