Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:46:12+00:00 2026-06-17T22:46:12+00:00

Script is successfully retrieving data but I can not get the results of the

  • 0

Script is successfully retrieving data but I can not get the results of the “row” to display using underscore.js. The specific point of failure is the “var = resultContentTemplate”. Can not figure this out.

$(document).ready(function(){
var symbols = symbols || ['GOOG','A','AA','AAN'];
var yqlUrl = "http://query.yahooapis.com/v1/public/yql";
var historicalUrl = 'http://finance.yahoo.com/d/quotes.csv';

var queryTemplate = _.template("select * from csv where url='" + historicalUrl + "?s=<%= symbol %>&f=n0s0l1' and columns='name,symbol,LastTradePriceOnly'");

var resultPlaceholderTemplate = _.template(
  '<li id="<%= id %>">Please wait, Loading quotes...</li>');


var resultContentTemplate = _.template(
  '<ul>'
  + '<li><% _.each(results, function(row) { %>'
  + '<%=row.name %>'
  + '<%=row.symbol %>'
  + '<%=row.LastTradePriceOnly %>'
  + '<% }); %>'
  + '</li>'
  + '</ul>');

// display the results of the query, replacing the 'loading' placeholder
function displayResult(id, queryResult, symbol) {
  var resultsAsHtml = resultContentTemplate({results: queryResult.row, symbol: symbol});
  $('#' + id).html(resultsAsHtml);
}

_.each(symbols, function(symbol) {

    var resultId = _.uniqueId();

    // lay down a placeholder
    $('#resultContainer').append(resultPlaceholderTemplate({id:resultId, symbol:symbol}));

    $.ajax({
      url: yqlUrl,
      data: {q: queryTemplate({symbol:symbol}), format: 'json'},
      context: $('#resultContainer')
    }).done(function(output) {
      console.log(output);
      var response = _.isString(output) ? JSON.parse(output) : output;
      displayResult(resultId, response.query.results, symbol);
    }).fail(function(err) {
      console.log('the thing failed with an error');
      console.log(err.responseText);
    });

});

});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:46:13+00:00Added an answer on June 17, 2026 at 10:46 pm

    See http://jsfiddle.net/mpBMK/

    Your code is making one ajax request per symbol. Hence, displayResult is called for each symbol, and queryResult parameter has only one child, the row for that symbol.

    The resultContentTemplate already gets the single row so you shouldn’t iterate over results. Instead:

    var resultContentTemplate = _.template(
    '<ul><li><%=result.name %><%=result.symbol %><%=result.LastTradePriceOnly %></li></ul>');
    
    ...
    //in displayResult(...) which is called once per symbol
    var resultsAsHtml = resultContentTemplate({result: queryResult.row, symbol: symbol});
    

    It should be clear by the fiddle what the issue was and how it can be fixed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an applescript that reads data from a CSV (successfully!). After my script
I have a script that successfully creates thumbnails but they're rendered low quality. Is
I have a PHP mail script that successfully sends emails to everything BUT GMail
I am using Pagedown version of Markdown and I have the script running successfully
I have a shell script that I can run successfully from the command line.
I have a script which successfully creates new nodes. But I'm having trouble setting
i have use java script successfully running in my project but when i have
I have a build script running successfully, but I am having a hard time
I have a script in which can successfully show OS and browser. I have
This script successfully generated the pdfs to a folder tmp/.... However the ZIP output

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.