javascript - Trying to call a value out of an array that is labeled as a number -
i had diffrent api before one. when run javascript can array when try append table tells me "uncaught syntaxerror: missing ) after argument list" don't know if because i'm trying call number or because working fine when had name value there. javascript.
var bitcoinapiurl = "https://crossorigin.me/http://api.bitcoincharts.com/v1/weighted_prices.json"; $(document).ready(function(){ $(".btn").on("click", function(){ var usercurrency = $('#usercurrency option:selected').text(); $("#div1").append("<p id='currencylabel' />"); $.ajax({ type: "get", url: bitcoinapiurl, datatype: "json", success: function(currency) { // loop through currency (var = 0; < currency.length; i++) { if(currency[i].usd == usercurrency) { var $tr = $("<tr class='hello' />"); $tr.append( $("<td />").text(currency[i]['24h'] )); $tr.append( $("<td />").text(currency[i].latest_trade || "information unavailable") ); $tr.append( $("<td />").text(currency[i].bid || "information unavailable") ); $tr.append( $("<td />").text(currency[i].high || "information unavailable") ); $("#thetable tbody").append($tr); } } $("#currencylabel").append(usercurrency); } }); }); });
this invalid:
$tr.append( $("<td />").text(currency[i].7d || "information unavailable") ); you can't have currency[i].7d. property name can't start digit. can however:
$tr.append( $("<td />").text(currency[i]['7d'] || "information unavailable") );
Comments
Post a Comment