Highcharts integration with YQL finance data in JSON format

Currently, I am utilizing jQuery and highcharts.js to develop a single line chart on my website that displays historical financial data for any company specified by the user. I have been experimenting with YQL and employed this query to fetch some quotes in JSON format:

select * from yahoo.finance.historicaldata where symbol = "AAPL" and startDate = "2013-02-01" and endDate = "2013-02-25"

Here is a link to the YQL console containing my query:

http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22AAPL%22%20and%20startDate%20%3D%20%222013-02-01%22%20and%20endDate%20%3D%20%222013-02-25%22

The output includes details about execution-start-time and execution-end-time, followed by the desired quotes:

"results": {
"quote": [
{
 "date": "2013-02-25",
 "Date": "2013-02-25",
 "Open": "453.85",
 "High": "455.12",
 "Low": "442.57",
 "Close": "442.80",
 "Volume": "13306400",
 "Adj_Close": "442.80"
},

I am encountering an issue extracting the Close price information from the results. I've attempted the following code without success:

    $.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22AAPL%22%20and%20startDate%20%3D%20%222013-02-01%22%20and%20endDate%20%3D%20%222013-02-25%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=cbfunc', function(data){

    console.log(data);

    var close = data.query.results.quote.close;
    document.write(close);

})

If anyone can assist me in identifying where my mistake lies, it would be greatly appreciated as I am new to jquery, yql, and json.

Thank you

Answer №1

From my perspective, it seems that the quote object being returned is an array. Have you made an attempt at:

var closePrice = data.query.results.quote[0].Close;
document.write(closePrice);

If not, consider setting a breakpoint on that specific line of code and analyzing the structure of the data object (e.g. using firebug).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are some methods for accessing jQuery ajax result data in Internet Explorer versions 7 or 8?

So, I'm facing an issue with retrieving the resultCount variable in different versions of Internet Explorer. int resultCount = 3; mav.addObject("resultCount", resultCount); This is how my jsp code looks like: $.ajax({ url: ...., type: &ap ...

Issue with Vuex store not being updated when called from promise resolution

I am facing an issue with my Vue.js application where I have an array called items bound to a Vuex data store and exposed as a computed property using the mapGetters helper. In the created() hook of the component, I make a REST API call to update this arra ...

Issues arise when attempting to use jQuery's $.post method in conjunction with a cakePHP controller,

I'm attempting to fetch a json array from a cakePHP controller using $.post(). I thought I wouldn't need a view file since I'll be setting autorender to false and expecting a json array. While I do get a response when using $.ajax and $.get, ...

What is the best way to conduct a conditional check across all subsequent visible rows of a table?

When a user clicks inside the text input field and presses either the down or up arrow keys, my JavaScript function is triggered. The purpose of this functionality is to search table values and allow the user to select one by pressing the arrow keys. Every ...

Command to conceal components for users visiting as guests

I'm looking to develop a directive that hides specific elements for guest users. Here is the current code I have: angular.module('someMod') .directive('premiumUser', premiumUser) .controller('PremiumUserCtrl', Pr ...

Using jQuery to delete data asynchronously with AJAX technology

I am currently working on a cart page that shows items in a user's shopping cart using ASP while retrieving data from a table. One of the features I have implemented is the ability for users to delete an entry by clicking on an image. I have successfu ...

Include image hover text without using HTML

I am looking to add a hover effect to some images using CSS and JS since I cannot directly edit the HTML file. The goal is to have centered text pop out when hovering over certain images. I know the div class of the image but unfortunately, I cannot add te ...

Unable to click on the icon when modifying Mui Text Field

Utilizing the MUI Text Field component, I have successfully added a select prop to transform it into a dropdown list with values and an icon. However, I encountered an issue while attempting to change the default dropdown icon to a custom one from Figma. D ...

How to extract JSON data enclosed within HTML tags in Android application

My issue is slightly different than what I expected when I previously asked: Parse JSON to configure android application. I am receiving a JSON object from the server, and when I view it in the browser's source code, this is how it appears: JOSON.co ...

Android has an issue with an undefined JSON array

Currently, I am utilizing Phonegap within an Android application. ownObject = InAppBilling.prototype.getAvailableProducts(successHandler, errorHandler); An ownObject is a JSON array providing the list of owned products as a parameter. However, when I att ...

What is the impact of util.inherits on the prototype chain in JavaScript?

Exploring this particular design: Function ConstrA () { EventEmitter.call(this); } util.inherits(ConstrA, EventEmitter); var obj = new ConstrA(); If util.inherits is omitted, ConstrA and obj will each establish their own distinct prototype chain. T ...

Is there a way to verify DNSSEC compatibility using node.js code?

Struggling with incorporating DNSSEC compliance checks into my web analytics tools using NodeJS. The standard library's dns module does not seem to accept DNSSEC record types such as rrsig, ds, nsec, and nsec3. Despite checking the documentation, thes ...

Instructions for validating an input field with yup to ensure it does not begin with '-', '+', or '_'

Is there a way to validate user input using YUP and restrict values that begin with '-', '+', or '_'? Thank you for your help! name: Yup.string() .required() .min(5, 'Too short') .matches(/^[aA-zZ&bso ...

Troubleshooting expressjs: Issues with serving Static Files

I've encountered a frustrating issue. Express js is not serving my static files as expected, and instead it keeps hitting my global catch all get handler. Here's how my directory structure looks: node/apps/web/app.js -------------/public/ ---- ...

Uploading multiple files with the help of prototype.js

Have been trying to figure out if it's possible to upload a file using only prototype and ajax. Unfortunately, my searches on Google have not yielded any helpful results. Would greatly appreciate any assistance with this issue. Thanks! ...

The console does not display the JSON data for requests and responses

I have successfully set up a server inside of VSCode, but unfortunately the request and response logs that I usually see in my terminal when running the server with npm start are not appearing. I would really like for them to display in the Debug Terminal ...

Footer positioned correctly with relative DIV

I find myself in a state of complete confusion. Coding is not exactly my forte, so I suspect I have made a significant error somewhere that is causing the following issue: My goal is to create a sticky footer. The footer does indeed stick to the bottom of ...

Transforming JSON Object to a Different Object using Mule ESB

My current process is as follows: <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/trackin ...

Obtaining a Variable Element through Selector

When working with Puppeteer, I am faced with the challenge of clicking on a web button that has a dynamic id like: #product-6852370-Size. Typically, I would use the following code: page.click('#product-6852370-Size'); However, the number withi ...

Creating nested objects from nested arrays in PHP is a simple task that involves iterating through the

Here is a code snippet that initializes a config: $this->config = array( 'users' => array( array('name' => 'admin', 'password' => $password ) ...