Best practices for selecting from multiple lists

Jan 9, 2015 at 2:50 PM
Good morning,

I'm working with two lists, and I'm wondering what the best way to work with both at the same time. I was thinking that perhaps a nested $.when statement might work, but I'm not sure what that would look like. Or, can I just place both $().SPServices.SPGetListItemsJson calls inside $(document).ready ?

Thanks very much in advance.
Coordinator
Jan 9, 2015 at 3:15 PM
You can read from as many lists as you want and process the results however you want. (How's that for a broad answer?) I've created arrays with dozens of promises for requests and done them one by one. It totally depends on what you want to do with the data.

M.
Jan 9, 2015 at 3:18 PM
Perhaps a broad answer for a broad question?

If I'm working with two separate lists, and want to compose the results into a single object list, say for visualization with d3, stuffing them all inside of a $(document).ready call seems too easy... this is totally valid though? Forgive me for not having more specifics (code), but I'm working on another dumb problem right now and I haven't even gotten to this part. SharePoint is mysterious.
Coordinator
Jan 9, 2015 at 3:22 PM
In this case, SharePoint is no different than any other service. You want data from two sources, so you query the two sources. Because you'll want both requests to complete before you process either (I think), you'll use promises to make sure you have the results before you move forward.

M.