I'm sorry, you guys. I really hate having to ask the question; I promise, I've been through as many other questions that look even tangentially related as my patience will allow.
Following the code from the following questions:
- jQuery when each is completed, trigger function
- jQuery AJAX solution inside each() loop
- How do I return the response from an asynchronous call?
I've got the following:
var XHR = [];
//This parses some selections on a screen, which, in turn, informs the URL inside the loop.
$("#list > input:checkbox:checked").each(function(){
result = [];
var list = $(this).val();
XHR.push($.ajax({
type:'GET',
url:"https://a-place.com/subsite/webapp/_api/web/lists/getByTitle('"+list+"')/items?$select=" + select + "&$filter=" + filter + "&$expand=" + expand + "&$top=10000",
dataType: "json",
headers: {Accept:"application/json;odata=verbose"},
complete:function(data){}
}));
});
$.when(XHR).then(function(data){
console.log(data);
});
No matter what I do, I'm only ever getting the promises inside that .when.then construction. I can't do anything with them, trying to access the responseJSON property, where all the actual objects are, does nothing. I've tried adding a return statement inside the complete callback function, that doesn't appear to change what's actually getting pushed into the XHR array.
Ideally, this is supposed to return a bunch of list items from one or more SharePoint lists that match the selected options and put the matched items into a single array that I can do stuff with.
Edit
Hmm. Ok, based on advice, I've tried:
success:function(data){}
And
success:function(data){return data.d.results;}
And nothing really changes in the console regardless of whether I use $.when.then or .done.
Thanks in advance.