Populate array with JSON data from URL

117 views
Skip to first unread message

Shawn

unread,
Jul 10, 2022, 6:48:27 PM7/10/22
to KnockoutJS
Im struggling with grabbing json data from a URL and adding it to an array, i cant seem to construct the array correctly. Any advice would be great.

The sample JSON data im grabbing is from https://randomuser.me/

Shawn

unread,
Jul 10, 2022, 6:58:54 PM7/10/22
to KnockoutJS
I forgot to ask. Does knockout require jquery to do stuff like this.

Jonathan Shay

unread,
Jul 10, 2022, 7:16:15 PM7/10/22
to knock...@googlegroups.com
Is the array an observable? Are the items in the array observable?

On Jul 10, 2022 6:48 PM, Shawn <shawnb...@gmail.com> wrote:
Im struggling with grabbing json data from a URL and adding it to an array, i cant seem to construct the array correctly. Any advice would be great.

The sample JSON data im grabbing is from https://randomuser.me/

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/knockoutjs/bf52d761-51dc-4368-ae9a-f6084bdd3662n%40googlegroups.com.

Shawn

unread,
Jul 10, 2022, 7:27:45 PM7/10/22
to KnockoutJS
No, currently they are not

Jonathan Shay

unread,
Jul 10, 2022, 7:43:55 PM7/10/22
to knock...@googlegroups.com
If you have a collection of objects returned in your ajax, simply iterate the collection and push each into your array. If the array isn't observable, however, you won't see any UI update.

Reply all
Reply to author
Forward
0 new messages