3 Replies Latest reply on Feb 13, 2014 10:50 PM by Bhess

    PI Web Services AJAX call from Chrome

    Bannikov

      Hello!

       

       

       

      We're implementing our own visualization on top of PI Web Services (as a data source) and faced with such problem. Our JavaScript AJAX code works well in Internet Explorer, but it fails in Chrome. As far as I've understood, this is because cross-domain scripting causes Chrome to perform OPTIONS request to PI Web Services, and PI Web Services (hosted in IIS) responds with 400 Bad Request.

       

      6866.Code.png

       

      8272.Error.png

       

      Can anybody help my with this issue?

        • Re: PI Web Services AJAX call from Chrome
          Bhess

          Yep, what you're seeing is a result of the browser's 'Same Origin' policy, which prevents against cross-site scripting (XSS) attacks.  The Same Origin policy prevents a page hosted at one site from making XMLHttpRequests to another site, since this is a method often employed by hackers to compromise user data, by convincing your browser to load phony scripts and content without your knowledge.

           

          There are two potential solutions to your problem using PI Web Services:

           

          -- Host your visualization service on the same server and port on which PI Web Services is installed

           

          -- "Wrap" the data access functionality available in PI Web Services within your visualization service, such that the AJAX client is actually calling the visualization service

           

          The long-term best answer here will be to use the PI Web API, which is now approaching its first official release.  The Web API features support for CORS (Cross-Origin Resource Sharing) out of the box, which is a technology that adds a security layer for cross-site requests.

            • Re: PI Web Services AJAX call from Chrome
              Bannikov

              Brad, thank you for your help!

               

               

               

              Brad Hess

              Host your visualization service on the same server and port on which PI Web Services is installed

               

              Unfortunately, we're using SharePoint as foundation for our visualisation, so we cannot install PI Web Services on the same servere on the same port; and when ports are differ, this issue appears. So we've only one way - make wrap-up service. Or maybe we can simply write redirection page? Can this be a solution?