2 Replies Latest reply on Aug 22, 2014 5:09 PM by Marcos Vainer Loeff

    Errors when working through Web API/HTML5 blog by Marcus

    GPaterson

      Hello,

       

      I'm new to the PI Web API and I'm trying to get the code in Marcus's blog to work. The post is here:

       

      https://vcampus.osisoft.com/bloggers_place/b/weblog/archive/2014/06/02/using-pi-web-api-beta-on-html5-with-jquery.aspx

       

      I'm new to javascript/jquery debugging so bear with me and let me know if I'm heading in the wrong direction.

       

      I am getting errors when trying to get the historical data, the snapshot data works. The errors I see are:

       


      You can see that the URL has "undefined" in it. I think I've traced this issue down to something that is happening within the JQuery library. When it executes the StartRetrievalMethod the RetrievalMethodData parameter is Undefined.

       

       

       
      function StartRetrievalMethod(PerformRequest, RetrievalMethodName, TableToAdd, RetrievalMethodClass, RetrievalMethodData ) {
      
          if (PerformRequest == "yes") {
              try {
                  for (var i = 0; i < RetrievalMethodData["Items"].length; i++) {
                      $('<tr/>', {
                          'id': RetrievalMethodName + 'Tr' + i,
                      }).appendTo(TableToAdd);
                      $('<td/>', {
                          'text': RetrievalMethodData["Items"]
      .Value
                      }).appendTo('#' + RetrievalMethodName + 'Tr' + i);
                      $('<td/>', {
                          'text': RetrievalMethodData["Items"]
      .Timestamp
                      }).appendTo('#' + RetrievalMethodName + 'Tr' + i);
                  }
              }
      

       

       

       The reason I say I think it's something with Jquery is that when the URL is passed to Jquery it looks ok. Here is the "Target" Url when it is inside of Jquery getting rattled around:

       

      file:///C:/inetpub/wwwroot/HTML5/pi_data_result.html?piServerName=OurServerName&piPointName=CDT158&startTime=*-1d&endTime=*&interval=1h&getsnap=yes&getrec=yes&getint=yes

       

      One major problem I have right now is that when debugging in firebug it hangs when it gets to return jqXHR inside of jquery so I can't step through that. Perhaps that's part of the problem?

       

      Any help or pointing me in the right direction is much appreciated.