4 Replies Latest reply: May 9, 2012 1:37 AM by yeti RSS

    No Data retrieved with AJAX Call HTMLDB_GET when using Safari Browser

    yeti
      In my apex (4.0) app i have certain page a which uses JS AJAX htmldb_get to pull some data from an on-demand process using xml structure
      -----
      var get = new htmldb_Get(null, $v('pFlowId'),
      'APPLICATION_PROCESS=get_markerdata', $v('pFlowStepId'));

      if (!MEBMarkerdataXML) {// Tabelle mit Kunden leer? Dann aus DB abfragen
      MEBMarkerdataXML = get.get('XML');
      }
      l_Count = MEBMarkerdataXML.getElementsByTagName("Kunde").length;
      -----
      I ran into a strange behavior when using Safari Browser (Mac and Windows) when opening the page.
      As long as the process retrieves less than 50 rows everything works fine. The data is pulled from the OnDemand Process and delivered to the browser; the XML Data can be selected in JS for further processing

      <<<<<<<<<<<<<< HTTP Traffic taken from Safari <<<<<<<<<<<<<<<
      Anfrage-URL:http://80.149.218.10:8080/apex/wwv_flow.show
      Anfragemethode:POST
      Status-Code:200 OK
      Anfrage
      Content-Type:application/x-www-form-urlencoded
      Origin:http://80.149.218.10:8080
      Referer:http://80.149.218.10:8080/apex/f?p=41107101:43:1599514482232751::
      User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3
      Formulardaten
      p_request:APPLICATION_PROCESS=get_markerdata
      p_instance:1599514482232751
      p_flow_id:41107101
      p_flow_step_id:43
      Antwort
      Cache-Control:no-cache
      Content-Type:text/xml;charset=UTF-8
      Date:Thu, 03 May 2012 10:19:35 GMT
      Pragma:no-cache
      Server:Apache-Coyote/1.1
      Transfer-Encoding:Identity
      X-DB-Content-length:53329
      X-ORACLE-IGNORE:IGNORE, IGNORE, IGNORE, IGNORE
      <<<<<<<<<<<<<<<<

      When calling for more then 50 rows Safaris shows a POST Error -1001 and no Data is delivered.

      This occurs only on some Mac's and my Dev WIN-XP PC using SF Browser; never on iPad/iPhone . Never when using FF on Mac or PC.
      I googled a lot of different Sources, it seems to be a Timeout Problem when making a long runing AJAX Call. But i did not find any useful hint.

      Any Ideas from the APEX & HTTP Gurus?

      Regards
      Peter
        • 1. Re: No Data retrieved with AJAX Call HTMLDB_GET when using Safari Browser
          Capt. Egg
          htmldb_Get.get() is evil, try something like this code instead...
          var get = new htmldb_Get(null, $v('pFlowId'),
          'APPLICATION_PROCESS=get_markerdata', $v('pFlowStepId'));
          
          if (!MEBMarkerdataXML) {// Tabelle mit Kunden leer? Dann aus DB abfragen
          
          get.GetAsync(function(){
              if(p.readyState == 4 && p.responseXML != ""){
                MEBMarkerdataXML = p.responseXML;
                l_Count = MEBMarkerdataXML.getElementsByTagName("Kunde").length;
             }
          }
          • 2. Re: No Data retrieved with AJAX Call HTMLDB_GET when using Safari Browser
            yeti
            hi cpt.jack,

            thanks for your approach. movin to asynch_get solved the prob. although i had to change some pieces of my implementation, so it could deal with the async delivery of the data.

            but i'd like to dig in somewhat deeper in the original cause of the problem. why did it only happen in safari n mac & pc?
            why does the timout error, u assume this was the problem, when using asynch get?

            would be great if you could enlighten the darkness of my inexperiance ;-)
            or at last, show me where to read more about it.
            • 3. Re: No Data retrieved with AJAX Call HTMLDB_GET when using Safari Browser
              Capt. Egg
              It's just that in my experience htmldb_Get.get() is troublesome for browsers, due to the fact it performs a synchronous request. The browser can do nothing else while it waits for the response. I've seen Firefox really struggle with it in the past couple years. Also, I've seen no good reason to use synchronous XMLHttpRequest calls. As you can see, it's simple to refactor a call to htmldb_Get.get() into a call to htmldb_Get.GetAsync().

              For your case in particular, I was just guessing Safari have implemented a timeout to ensure that they don't end up waiting indefinitely for a request that never returns as this would be fatal. You're probably hitting that timeout.

              I don't think htmldb_Get is officially documented anywhere, but you can find the source here... http://apex.oracle.com/i/javascript/uncompressed/apex_4_0.js

              There is also a pure jQuery way to perform AJAX request, I recommend using this because at least it's documented. Here's a snippet of a typical APEX AJAX request done the jQuery way:
              apex.jQuery.ajax({
                dataType: "xml", //supports text, xml, json, jsonp, script, or html
                type: "post",
                url: "wwv_flow.show",
                traditional: true,
                data: {
                  p_request: "APPLICATION_PROCESS=get_markerdata",
                  p_flow_id: $("#pFlowId").val(),
                  p_flow_step_id: $("#pFlowStepId").val(),
                  p_instance: $("#pInstance").val()
                },
                success: function (data, textStatus, jqXHR) {
                  // Do your thing in here
                },
                error: function (xhr, ajaxOptions, thrownError) {
                  // Handle error in here
                }
              });
              Then you can refer to great documentation here... http://api.jquery.com/jQuery.ajax/
              • 4. Re: No Data retrieved with AJAX Call HTMLDB_GET when using Safari Browser
                yeti
                excellent explanation. thanks a lot