jquery - Having trouble getting to the JSON response after promises resolve -


i'm sorry, guys. hate having ask question; promise, i've been through many other questions tangentially related patience allow.

following code following questions:

i've got following:

var xhr = [];  //this parses selections on screen, which, in turn, informs url inside 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 do, i'm ever getting promises inside .when.then construction. can't them, trying access responsejson property, actual objects are, nothing. i've tried adding return statement inside complete callback function, doesn't appear change what's getting pushed xhr array.

ideally, supposed return bunch of list items 1 or more sharepoint lists match selected options , put matched items single array can stuff with.

edit

hmm. ok, based on advice, i've tried:

success:function(data){} 

and

success:function(data){return data.d.results;} 

and nothing changes in console regardless of whether use $.when.then or .done.

thanks in advance.

you can try collecting results in success callback, , use afterwards in 'then' function callback:

var results = []; ... success: function(data){     results.push(data.d.results); } ... $.when(xhr).then(function(){    // here should have results filled in    console.log(results); }); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -