Last active
September 17, 2020 11:57
-
-
Save rhalp10/8a05d9beb1d4dac5794bd2aca1aa58a7 to your computer and use it in GitHub Desktop.
AJAX Object.length undefined in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF YOU ARE HAVING PROBLEM ON USING AJAX JSON AND THE DATA IS "UNDEFINED" AND CANNOT COUNT THE LENGHT. | |
I WOULD RECOMMEND TO USE THIS. | |
var jsonDataFromAjax = {}; | |
var keys = Object.keys(jsonDataFromAjax); | |
for (var i = 0, len = keys.length; i < len; i++) { | |
console.log(jsonDataFromAjax[keys[i]]); | |
} | |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment