javascript - Variable not working in Json object as key after .replace() function is run on that variable? -


json not accept variable storing url after using .replace() on variable (myimg) seen below:

$.get('http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/'+user_name+'/tracks&client_id='+my_client_id,        function (result) {         (var = 0; < result.length; i++) {             var myimg = result[i].artwork_url;             var myimg = myimg.replace('-large', '-t500x500'); //problem line of code making  variable not usable in json object below.              trackdata[i] = {                              title: result[i].title,                              mp3: result[i].stream_url + '?client_id=' + my_client_id,                              url: result[i].permalink_url,                              poster: myimg, // not working if use .replace() on myimg var above , works without                              sc: "true"                            }          }     (i = 0; < trackdata.length; i++) {         playlist.push(trackdata[i]);     }   }); 

if take out line :

var myimg = myimg.replace('-large', '-t500x500'); 

the variable work,however replace string in url before passing json object. allow me update url higher quality image detailed in question: soundcloud 500x500 artwork default

move

for (i = 0; < trackdata.length; i++) {   playlist.push(trackdata[i]); } 

inside of $.get, looks race condition (assuming problem "the image isn't showing on web page", , not javascript error per se).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -