ICEfaces
  1. ICEfaces
  2. ICE-10294

Unable to access BridgeIt when page is first loaded using ajax (must be a GET)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.0
    • Labels:
      None
    • Environment:
      jsf2 bridgeit mobi
    • Assignee Priority:
      P1
    • Workaround Exists:
      Yes
    • Workaround Description:
      load bridgeit.js on mobile-showcase.xhtml page for now.

      Description

      can only access bridgeit.js from a Get and not an XMLHttprequest (ajax).
      or get the following error:-

      XMLHttpRequest cannot load http://bridgeit.github.io/bridgeit.js/src/bridgeit.js?v=4_0_0_141001. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://10.18.39.137:8080' is therefore not allowed access.
      ......
      Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://bridgeit.github.io/bridgeit.js/src/bridgeit.js?v=4_0_0_141001'.
      1. Picture 2.png
        49 kB
      2. Picture 1.png
        16 kB

        Issue Links

          Activity

          Hide
          Ken Fyten added a comment -

          This can be tested by removing the "bridgeit.js" load from the showcase-mobile.xhtml page. Then it will attempt to load bridgeit.js using ajax techniques when you first select one of the native mobi demos (and will fail).

          Show
          Ken Fyten added a comment - This can be tested by removing the "bridgeit.js" load from the showcase-mobile.xhtml page. Then it will attempt to load bridgeit.js using ajax techniques when you first select one of the native mobi demos (and will fail).
          Hide
          Ken Fyten added a comment -

          Note that the following attempts at an application-level workaround for this have failed:

          1. Trying to load the bridgeit.js directly in the main page fails to avoid the JS error when a native mobi component demo is selected.
          2. Using mandatoryResourceConfig to force load the bridgeit.js file on initial page load. Still logs the JS error when the native mobi component demo is selected, as I guess it still tries to load bridgeit.js again via ajax (shouldn't it be smart enough to know it's already loaded?)

          This is becoming a problem. Any idea why #2 doesn't work?

          Perhaps if the JS is successfully loaded via mandatoryResourceConfig, then the error on ajax update could be trapped and logged as warn or something but not break the app.?

          Show
          Ken Fyten added a comment - Note that the following attempts at an application-level workaround for this have failed: Trying to load the bridgeit.js directly in the main page fails to avoid the JS error when a native mobi component demo is selected. Using mandatoryResourceConfig to force load the bridgeit.js file on initial page load. Still logs the JS error when the native mobi component demo is selected, as I guess it still tries to load bridgeit.js again via ajax (shouldn't it be smart enough to know it's already loaded?) This is becoming a problem. Any idea why #2 doesn't work? Perhaps if the JS is successfully loaded via mandatoryResourceConfig, then the error on ajax update could be trapped and logged as warn or something but not break the app.?
          Hide
          Mircea Toma added a comment -

          The "No 'Access-Control-Allow-Origin' header is present on the requested resource." error is raised because the JS resource was requested from a different domain (bridgeit.github.io) than the one the page was loaded from (10.18.39.137). This is a restriction imposed by modern browsers for the AJAX requests.

          To solve this problem bridgeit.github.io server will need to send the proper CORS headers. Please see http://en.wikipedia.org/wiki/Cross-origin_resource_sharing .

          Show
          Mircea Toma added a comment - The "No 'Access-Control-Allow-Origin' header is present on the requested resource." error is raised because the JS resource was requested from a different domain ( bridgeit.github.io ) than the one the page was loaded from ( 10.18.39.137 ). This is a restriction imposed by modern browsers for the AJAX requests. To solve this problem bridgeit.github.io server will need to send the proper CORS headers. Please see http://en.wikipedia.org/wiki/Cross-origin_resource_sharing .
          Hide
          Philip Breau added a comment -

          I put the following files on api.bridgeit.mobi:

          http://api.bridgeit.mobi/bridgeit/v1.0.4/bridgeit.js
          http://api.bridgeit.mobi/bridgeit/v1.x-latest/bridgeit.js

          But currently there do not seem to be any CORS headers being set on those requests.

          Show
          Philip Breau added a comment - I put the following files on api.bridgeit.mobi: http://api.bridgeit.mobi/bridgeit/v1.0.4/bridgeit.js http://api.bridgeit.mobi/bridgeit/v1.x-latest/bridgeit.js But currently there do not seem to be any CORS headers being set on those requests.
          Hide
          Jack Van Ooststroom added a comment -

          The bridgeit.war on api.bridgeit.mobi was a handcrafted .war-file. I updated this by including a web.xml and the CustomHeaderFilter from NaaS, to ensure the Access-Control-Allow-Origin header is set to * for now. If we need additional fine tuning of the CORS headers, we should be able to configure this in the web.xml.

          Show
          Jack Van Ooststroom added a comment - The bridgeit.war on api.bridgeit.mobi was a handcrafted .war-file. I updated this by including a web.xml and the CustomHeaderFilter from NaaS, to ensure the Access-Control-Allow-Origin header is set to * for now. If we need additional fine tuning of the CORS headers, we should be able to configure this in the web.xml.
          Hide
          Jack Van Ooststroom added a comment -

          SyntaxError in Chrome Console

          Show
          Jack Van Ooststroom added a comment - SyntaxError in Chrome Console
          Hide
          Jack Van Ooststroom added a comment -

          I see a SyntaxError when trying to open Showcase -> Mobile -> Fetch Contact. See attached picture for details.

          Show
          Jack Van Ooststroom added a comment - I see a SyntaxError when trying to open Showcase -> Mobile -> Fetch Contact. See attached picture for details.
          Hide
          Jack Van Ooststroom added a comment -

          Now with line numbers.

          Show
          Jack Van Ooststroom added a comment - Now with line numbers.
          Hide
          Ken Fyten added a comment -

          This is now working as expected.

          Show
          Ken Fyten added a comment - This is now working as expected.

            People

            • Assignee:
              Jack Van Ooststroom
              Reporter:
              Judy Guglielmin
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: