0

So the array prints to the console like below when I do console.log(results) but when I do console.log(results[0]) it returns undefined and when I do console.log(results['length']) it returns 0 when it is clearly labeled as 27 (i've removed lines to fit the character limit). I don't get what I'm doing wrong, any help would be appreciated. You can see my code for printing it from Ajax below too, this is formatted like this purely for testing and won't be like this once I can sort out the issue. Also the Ajax prints Song List: when I just have results after 'q=' so the values aren't going through the Ajax at all. I've tried with and without doing JSON.stringify on the values in the array, they currently are stringified below.

Array:

[]
    0: "{"_album":{"album_type":"single","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"},"href":"https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02","id":"06HL4z0CvFAxyc27GXpf02","name":"Taylor Swift","type":"artist","uri":"spotify:artist:06HL4z0CvFAxyc27GXpf02"}],"available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"external_urls":{"spotify":"https://open.spotify.com/album/7cfhaRiLqBzuAzc6Q24nyW"},"href":"https://api.spotify.com/v1/albums/7cfhaRiLqBzuAzc6Q24nyW","id":"7cfhaRiLqBzuAzc6Q24nyW","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b2738d3b185c6a110a479e01e3c4","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e028d3b185c6a110a479e01e3c4","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d000048518d3b185c6a110a479e01e3c4","width":64}],"name":"Today Was A Fairytale","release_date":"2011-02-15","release_date_precision":"day","total_tracks":1,"type":"album","uri":"spotify:album:7cfhaRiLqBzuAzc6Q24nyW"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"},"href":"https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02","id":"06HL4z0CvFAxyc27GXpf02","name":"Taylor Swift","type":"artist","uri":"spotify:artist:06HL4z0CvFAxyc27GXpf02"}],"_available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"_disc_number":1,"_duration_ms":242480,"_explicit":false,"_external_ids":{"isrc":"USCJY1103825"},"_external_urls":{"spotify":"https://open.spotify.com/track/4pFvEWbjBpPUdYRQly0THs"},"_href":"https://api.spotify.com/v1/tracks/4pFvEWbjBpPUdYRQly0THs","_id":"4pFvEWbjBpPUdYRQly0THs","_name":"Today Was A Fairytale","_popularity":54,"_preview_url":null,"_track_number":1,"_type":"track","_uri":"spotify:track:4pFvEWbjBpPUdYRQly0THs"}"
    1: "{"_album":{"album_type":"album","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/07YZf4WDAMNwqr4jfgOZ8y"},"href":"https://api.spotify.com/v1/artists/07YZf4WDAMNwqr4jfgOZ8y","id":"07YZf4WDAMNwqr4jfgOZ8y","name":"Jason Derulo","type":"artist","uri":"spotify:artist:07YZf4WDAMNwqr4jfgOZ8y"}],"available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","UY","VN","XK","ZA"],"external_urls":{"spotify":"https://open.spotify.com/album/0DEsmIQ5ir7tz52Nkf4i1K"},"href":"https://api.spotify.com/v1/albums/0DEsmIQ5ir7tz52Nkf4i1K","id":"0DEsmIQ5ir7tz52Nkf4i1K","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b273291365c950592bee8e415f63","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e02291365c950592bee8e415f63","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d00004851291365c950592bee8e415f63","width":64}],"name":"Jason Derulo (International)","release_date":"2010-02-26","release_date_precision":"day","total_tracks":10,"type":"album","uri":"spotify:album:0DEsmIQ5ir7tz52Nkf4i1K"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/07YZf4WDAMNwqr4jfgOZ8y"},"href":"https://api.spotify.com/v1/artists/07YZf4WDAMNwqr4jfgOZ8y","id":"07YZf4WDAMNwqr4jfgOZ8y","name":"Jason Derulo","type":"artist","uri":"spotify:artist:07YZf4WDAMNwqr4jfgOZ8y"}],"_available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","UY","VN","XK","ZA"],"_disc_number":1,"_duration_ms":221253,"_explicit":false,"_external_ids":{"isrc":"USWB10901504"},"_external_urls":{"spotify":"https://open.spotify.com/track/7xkQdy0cy5ymoWT7nedvLz"},"_href":"https://api.spotify.com/v1/tracks/7xkQdy0cy5ymoWT7nedvLz","_id":"7xkQdy0cy5ymoWT7nedvLz","_name":"Whatcha Say","_popularity":73,"_preview_url":"https://p.scdn.co/mp3-preview/9c0288e332c151689bf465a3f8b52a6c9d056e3a?cid=f60640122c2241779f23dbf63991b55f","_track_number":1,"_type":"track","_uri":"spotify:track:7xkQdy0cy5ymoWT7nedvLz"}"
    2: "{"_album":{"album_type":"album","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/0LyfQWJT6nXafLPZqxe9Of"},"href":"https://api.spotify.com/v1/artists/0LyfQWJT6nXafLPZqxe9Of","id":"0LyfQWJT6nXafLPZqxe9Of","name":"Various Artists","type":"artist","uri":"spotify:artist:0LyfQWJT6nXafLPZqxe9Of"}],"available_markets":["AD","AE","AL","AR","AT","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"external_urls":{"spotify":"https://open.spotify.com/album/40fkeTlzY3ZNVUkyjmZAZT"},"href":"https://api.spotify.com/v1/albums/40fkeTlzY3ZNVUkyjmZAZT","id":"40fkeTlzY3ZNVUkyjmZAZT","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b2736f7076f8fd9c1c0a45062c7c","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e026f7076f8fd9c1c0a45062c7c","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d000048516f7076f8fd9c1c0a45062c7c","width":64}],"name":"In My Head: Party All Night","release_date":"2020-09-04","release_date_precision":"day","total_tracks":23,"type":"album","uri":"spotify:album:40fkeTlzY3ZNVUkyjmZAZT"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/07YZf4WDAMNwqr4jfgOZ8y"},"href":"https://api.spotify.com/v1/artists/07YZf4WDAMNwqr4jfgOZ8y","id":"07YZf4WDAMNwqr4jfgOZ8y","name":"Jason Derulo","type":"artist","uri":"spotify:artist:07YZf4WDAMNwqr4jfgOZ8y"}],"_available_markets":["AD","AE","AL","AR","AT","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"_disc_number":1,"_duration_ms":198960,"_explicit":false,"_external_ids":{"isrc":"USWB10904633"},"_external_urls":{"spotify":"https://open.spotify.com/track/3sg5Oz42qIq40Z9b9SSpnu"},"_href":"https://api.spotify.com/v1/tracks/3sg5Oz42qIq40Z9b9SSpnu","_id":"3sg5Oz42qIq40Z9b9SSpnu","_name":"In My Head","_popularity":10,"_preview_url":"https://p.scdn.co/mp3-preview/74a7567fd95d1ca20a8d4e8aea523dfa515e9da6?cid=f60640122c2241779f23dbf63991b55f","_track_number":1,"_type":"track","_uri":"spotify:track:3sg5Oz42qIq40Z9b9SSpnu"}"
    3: "{"_album":{"album_type":"album","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/3DiDSECUqqY1AuBP8qtaIa"},"href":"https://api.spotify.com/v1/artists/3DiDSECUqqY1AuBP8qtaIa","id":"3DiDSECUqqY1AuBP8qtaIa","name":"Alicia Keys","type":"artist","uri":"spotify:artist:3DiDSECUqqY1AuBP8qtaIa"}],"available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"external_urls":{"spotify":"https://open.spotify.com/album/0Rxab8t0y7GlaTJTHX2wEN"},"href":"https://api.spotify.com/v1/albums/0Rxab8t0y7GlaTJTHX2wEN","id":"0Rxab8t0y7GlaTJTHX2wEN","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b273fe6a98e875958c7d7080584e","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e02fe6a98e875958c7d7080584e","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d00004851fe6a98e875958c7d7080584e","width":64}],"name":"The Element Of Freedom","release_date":"2009-12-15","release_date_precision":"day","total_tracks":14,"type":"album","uri":"spotify:album:0Rxab8t0y7GlaTJTHX2wEN"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/3DiDSECUqqY1AuBP8qtaIa"},"href":"https://api.spotify.com/v1/artists/3DiDSECUqqY1AuBP8qtaIa","id":"3DiDSECUqqY1AuBP8qtaIa","name":"Alicia Keys","type":"artist","uri":"spotify:artist:3DiDSECUqqY1AuBP8qtaIa"}],"_available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"_disc_number":1,"_duration_ms":249240,"_explicit":false,"_external_ids":{"isrc":"USJAY0900287"},"_external_urls":{"spotify":"https://open.spotify.com/track/4JOP8ELK6AaeySe7sKe996"},"_href":"https://api.spotify.com/v1/tracks/4JOP8ELK6AaeySe7sKe996","_id":"4JOP8ELK6AaeySe7sKe996","_name":"Un-thinkable (I'm Ready)","_popularity":65,"_preview_url":"https://p.scdn.co/mp3-preview/df023747fdd196e3c286e0ef70dfbf476b1a4a3b?cid=f60640122c2241779f23dbf63991b55f","_track_number":7,"_type":"track","_uri":"spotify:track:4JOP8ELK6AaeySe7sKe996"}"
    4: "{"_album":{"album_type":"album","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms"},"href":"https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms","id":"1HY2Jd0NmPuamShAr6KMms","name":"Lady Gaga","type":"artist","uri":"spotify:artist:1HY2Jd0NmPuamShAr6KMms"}],"available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"external_urls":{"spotify":"https://open.spotify.com/album/6rePArBMb5nLWEaY9aQqL4"},"href":"https://api.spotify.com/v1/albums/6rePArBMb5nLWEaY9aQqL4","id":"6rePArBMb5nLWEaY9aQqL4","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b2735c9890c0456a3719eeecd8aa","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e025c9890c0456a3719eeecd8aa","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d000048515c9890c0456a3719eeecd8aa","width":64}],"name":"The Fame Monster (Deluxe Edition)","release_date":"2009-11-05","release_date_precision":"day","total_tracks":23,"type":"album","uri":"spotify:album:6rePArBMb5nLWEaY9aQqL4"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/1HY2Jd0NmPuamShAr6KMms"},"href":"https://api.spotify.com/v1/artists/1HY2Jd0NmPuamShAr6KMms","id":"1HY2Jd0NmPuamShAr6KMms","name":"Lady Gaga","type":"artist","uri":"spotify:artist:1HY2Jd0NmPuamShAr6KMms"}],"_available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PS","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"_disc_number":1,"_duration_ms":294573,"_explicit":true,"_external_ids":{"isrc":"USUM70918596"},"_external_urls":{"spotify":"https://open.spotify.com/track/0SiywuOBRcynK0uKGWdCnn"},"_href":"https://api.spotify.com/v1/tracks/0SiywuOBRcynK0uKGWdCnn","_id":"0SiywuOBRcynK0uKGWdCnn","_name":"Bad Romance","_popularity":81,"_preview_url":null,"_track_number":1,"_type":"track","_uri":"spotify:track:0SiywuOBRcynK0uKGWdCnn"}"
    5: "{"_album":{"album_type":"album","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/5ndkK3dpZLKtBklKjxNQwT"},"href":"https://api.spotify.com/v1/artists/5ndkK3dpZLKtBklKjxNQwT","id":"5ndkK3dpZLKtBklKjxNQwT","name":"B.o.B","type":"artist","uri":"spotify:artist:5ndkK3dpZLKtBklKjxNQwT"}],"available_markets":["AT","BE","BG","CH","CY","CZ","DE","EE","GB","GR","HU","IE","LT","LU","LV","MT","NL","PL","PT","RO","SI","SK"],"external_urls":{"spotify":"https://open.spotify.com/album/6f06neONZ0xqqftlgtVP74"},"href":"https://api.spotify.com/v1/albums/6f06neONZ0xqqftlgtVP74","id":"6f06neONZ0xqqftlgtVP74","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b273447efa80cb185be0fbbb9a4d","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e02447efa80cb185be0fbbb9a4d","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d00004851447efa80cb185be0fbbb9a4d","width":64}],"name":"B.o.B Presents: The Adventures of Bobby Ray","release_date":"2010-04-27","release_date_precision":"day","total_tracks":15,"type":"album","uri":"spotify:album:6f06neONZ0xqqftlgtVP74"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/5ndkK3dpZLKtBklKjxNQwT"},"href":"https://api.spotify.com/v1/artists/5ndkK3dpZLKtBklKjxNQwT","id":"5ndkK3dpZLKtBklKjxNQwT","name":"B.o.B","type":"artist","uri":"spotify:artist:5ndkK3dpZLKtBklKjxNQwT"},{"external_urls":{"spotify":"https://open.spotify.com/artist/0du5cEVh5yTK9QJze8zA0C"},"href":"https://api.spotify.com/v1/artists/0du5cEVh5yTK9QJze8zA0C","id":"0du5cEVh5yTK9QJze8zA0C","name":"Bruno Mars","type":"artist","uri":"spotify:artist:0du5cEVh5yTK9QJze8zA0C"}],"_available_markets":["AT","BE","BG","CH","CY","CZ","DE","EE","GB","GR","HU","IE","LT","LU","LV","MT","NL","PL","PT","RO","SI","SK"],"_disc_number":1,"_duration_ms":268320,"_explicit":false,"_external_ids":{"isrc":"USAT20904033"},"_external_urls":{"spotify":"https://open.spotify.com/track/4X5xWMINgGA6l0GoyYkMcr"},"_href":"https://api.spotify.com/v1/tracks/4X5xWMINgGA6l0GoyYkMcr","_id":"4X5xWMINgGA6l0GoyYkMcr","_name":"Nothin' on You (feat. Bruno Mars)","_popularity":62,"_preview_url":"https://p.scdn.co/mp3-preview/cb93cd5770a3ff6824d8cfcb7e743c9be99c0246?cid=f60640122c2241779f23dbf63991b55f","_track_number":2,"_type":"track","_uri":"spotify:track:4X5xWMINgGA6l0GoyYkMcr"}"
    6: "{"_album":{"album_type":"album","artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/5pKCCKE2ajJHZ9KAiaK11H"},"href":"https://api.spotify.com/v1/artists/5pKCCKE2ajJHZ9KAiaK11H","id":"5pKCCKE2ajJHZ9KAiaK11H","name":"Rihanna","type":"artist","uri":"spotify:artist:5pKCCKE2ajJHZ9KAiaK11H"}],"available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"external_urls":{"spotify":"https://open.spotify.com/album/7uGmyYwDFJbSc1xs4hkEs2"},"href":"https://api.spotify.com/v1/albums/7uGmyYwDFJbSc1xs4hkEs2","id":"7uGmyYwDFJbSc1xs4hkEs2","images":[{"height":640,"url":"https://i.scdn.co/image/ab67616d0000b273ab647295c0c97446c1f1a3b5","width":640},{"height":300,"url":"https://i.scdn.co/image/ab67616d00001e02ab647295c0c97446c1f1a3b5","width":300},{"height":64,"url":"https://i.scdn.co/image/ab67616d00004851ab647295c0c97446c1f1a3b5","width":64}],"name":"Rated R","release_date":"2009-11-20","release_date_precision":"day","total_tracks":13,"type":"album","uri":"spotify:album:7uGmyYwDFJbSc1xs4hkEs2"},"_artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/5pKCCKE2ajJHZ9KAiaK11H"},"href":"https://api.spotify.com/v1/artists/5pKCCKE2ajJHZ9KAiaK11H","id":"5pKCCKE2ajJHZ9KAiaK11H","name":"Rihanna","type":"artist","uri":"spotify:artist:5pKCCKE2ajJHZ9KAiaK11H"}],"_available_markets":["AD","AE","AL","AR","AT","AU","BA","BE","BG","BH","BO","BR","BY","CA","CH","CL","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GB","GR","GT","HK","HN","HR","HU","ID","IE","IL","IN","IS","IT","JO","JP","KW","KZ","LB","LI","LT","LU","LV","MA","MC","MD","ME","MK","MT","MX","MY","NI","NL","NO","NZ","OM","PA","PE","PH","PL","PT","PY","QA","RO","RS","RU","SA","SE","SG","SI","SK","SV","TH","TN","TR","TW","UA","US","UY","VN","XK","ZA"],"_disc_number":1,"_duration_ms":222920,"_explicit":true,"_external_ids":{"isrc":"USUM70912459"},"_external_urls":{"spotify":"https://open.spotify.com/track/60jzFy6Nn4M0iD1d94oteF"},"_href":"https://api.spotify.com/v1/tracks/60jzFy6Nn4M0iD1d94oteF","_id":"60jzFy6Nn4M0iD1d94oteF","_name":"Rude Boy","_popularity":74,"_preview_url":null,"_track_number":8,"_type":"track","_uri":"spotify:track:60jzFy6Nn4M0iD1d94oteF"}"
...
    length: 27
    __proto__: Array(0)

Ajax:

$(document).ready(function(){
    $.ajax({
        type: 'POST',
        data: 'q=' + console.log(results) + console.log(results[0]),
        success: function(songs){
            $('#response').text('Song List: ' + songs);
        }
    });
});
M. F.
  • 11
  • 1
  • Why are you trying to use console.log in a string concatenation context!?! – CBroe Sep 08 '20 at 09:34
  • 1
    See the linked question's answers for details, but what's happening is that the array is empty as of the `console.log(results)` statement executing (which is why `results[0]` is `undefined`). But the console keeps a live reference to the array, and later when you expand the array in the console, it shows you its contents **then**. You're trying to use the array before it's been filled in. – T.J. Crowder Sep 08 '20 at 09:36

0 Answers0