Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Question was updated:</strong></p> <p><s>You are redeclaring a local variable in your first request named <code>token</code>, so it doesn't use the global <code>token</code> that you initiated with <code>null</code>.</p> <p>Remove the <code>var</code> keyword in the first request.</p> <pre><code>token = tokenArray[3]; </code></pre> <p></s></p> <p>If the requests run sequentially, then the second will not wait for the first to receive its response before it executes.</p> <p>If that's the case, place the second request in a <code>function</code>, and call that function from the <code>success:</code> callback in the first.</p> <pre><code>$.ajax({ type: "POST", url: "https://" + host + clientLoginEntryPoint, data: cLRequestData(accountType, user, pwd, service), dataType: "html", success: function (response) { var tokenArray = response.split("="); // Split to response tokenArray[3] is the auth token token = tokenArray[3]; $(".status").html(token); // Call second request here secondRequest( token ); // optionally pass the "token" // instead of using global var } }); // END OF CLIENT LOGIN REQUEST function secondRequest( token ) { $.ajax({ type: "GET", url: "http://" + host + googleContactEntryPoint, beforeSend: function(xhr) { xhr.setRequestHeader('Authorization', 'GoogleLogin auth=' + token); xhr.setRequestHeader('GData-Version', '3.0'); }, success: function(response, textStatus, xhr) { var names = $(response).find('entry&gt;title').text(); $(".status").text(names); }, error: function(xhr, status, error) { $(".status").html(xhr.status+ "&amp;nbsp;"+ xhr.statusText ); } }) } </code></pre> <p><em>(In this code, you could actually get rid of the global <code>token</code> variable, and just pass the <code>token</code> from the first request to the second as a function parameter.)</em></p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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