Javascript API

BrendonUnland
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 08/25/2009
Points: 20

Hi,

I'm trying to use the documentation for the javascript API and I am missing something.  Why does this not work? I am expecting the values to be returned and displayed on the browser.  I've tried the same parameters--I registered and got my own username and password with XIgnite--in Wires and it works as expected.  Thanks!

<html>

    <head>
        <title>Samples Page with Presto Connect</title>
    </head>

    <body>
        <script language="javascript" src="http://localhost:8080/static/common/js/prototype/prototype-1.6.0.js"></script>
        <script language="Javascript" src="http://localhost:8080/static/common/js/presto-util.js"></script>
        <script language="Javascript" src="http://localhost:8080/static/common/js/presto-connect.js"></script>
        <script language="Javascript" type"text/Javascript">
           
               
           

prestoUrl = "/presto";
var connection = new Presto.Connection({username: 'admin', password: 'adminadmin'});

function invokeXigniteHistorical() {
  connection.request({ //request configuration
    sid: 'XigniteHistorical',
    oid: 'GetHistoricalQuotesAsOf',
    header: {
      serviceHeader: {
        "ser:header": {
          "ser:Username": "mysuername@aol.com"
        "ser:Password": "mypassword"
        }
      }
    },
    //input parameters
    params: {
        "ser:GetHistoricalQuotesAsOf": {
          "ser:Identifier": "GOOG",
          "ser:IdentifierType": "Symbol",
          "ser:EndDate": "10/7/2009",
         
        }
    }
  },
  { //callback
    onSuccess: function(response) {
      console.log('XigniteHistorical response = ');
      console.log(data.response);
      alert('XigniteHistorical success');
    },
    onFailure: function(err) {
      alert('XigniteHistorical failure = ' + err.message);
    },
    scope: this
  });
}           

</script>
       
    </body/
</html>

 

0
Your rating: None
aishmishra
aishmishra's picture
User offline. Last seen 10 weeks 5 days ago. Offline
Joined: 09/24/2008
Points: 3

Hi,

Could you try the revised script which is attached?

One reason why you could not see data was because the invokeXigniteHistorical function was not being executed.

I added it to the onLoad function of the body tag.

Plus, I think you should change data.response to response. There is no object called data though there is an object called response.

Do let us know how it goes.

aishmishra
aishmishra's picture
User offline. Last seen 10 weeks 5 days ago. Offline
Joined: 09/24/2008
Points: 3

 please also remember that we have used console.log statements to display data.

Which means you will not see the data on screen but in the console - you can view the console in Firefox using the Firebug addon.

If you wish you see it as an alert just replace the console.log with alert

Hope this helps.

BrendonUnland
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 08/25/2009
Points: 20

Ok,

Alert pops up with message:  XigniteHistorical failure = Access to restricted URI denied

I am using the same parameters in Wires and I get a valid response.

aishmishra
aishmishra's picture
User offline. Last seen 10 weeks 5 days ago. Offline
Joined: 09/24/2008
Points: 3

Can you paste the Firebug log here?

It worked for me though.

Aishwarya