Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my Jquery ajax success handler being called with an array (and not the response object)
    primarykey
    data
    text
    <p>I have a function which makes two rest calls to the google spreadsheetAPI. I use a $.when to make sure that the data fron thefirst call is process before dealing with the data from the second call.</p> <p>The problem is that the first ajax handler(getRealNames), receives a javascript object as its argument, but the second handler(displayTeams), receives an array, the 0th element is the object I was expecting to get.</p> <p>Why does one get an object and the other get an array? They are calling the same rest api. The array did not appear until I refactored the code to use deferreds instead of callback nesting. So I think this is a jquery question rather than a spreadsheetAPI question.</p> <p>(see screen shot below, I've console.log'ed the arguments received by both handlers </p> <pre><code>//this is the function generating the REST requests, I just put it in for completeness function getWorkSheet(doc_key,sheet){ return $.get('https://spreadsheets.google.com/feeds/list/'+ doc_key+'/'+sheet+ '/private/full?alt=json&amp;access_token=' + googleAPItoken) .fail(function(){ alert("failed to get google doc:"+doc_key+" ,sheet: "+sheet); }); } function getRWMTeams() { var nameQuery=getWorkSheet(doc_key,1); nameQuery.done(getRealNames); var repoQuery=getWorkSheet(doc_key,2); //the deferred:'namesProcessed' is resolved in getRealNames $.when(repoQuery,namesProcessed) .done(displayTeams); } </code></pre> <p><img src="https://i.stack.imgur.com/uvD2M.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload