0

I am new to jQuery and API. I want to store $.ajax response into a variable but I am getting an output as [object object] instead of token string. My code is below:

var result=$.ajax({  
             "async": true,
              "crossDomain": true,
              "url": "https://.........../api/v1/sdk_initialize", 
              "method": "GET",
              "headers": {
                 "Content-Type": "application/json",
                 "cache-control": "no-cache",
                 "Authorization": "Basic .........=",
              },
              success: function(response) {
                  return response;
              }
          });

alert(result);
scraaappy
  • 2,830
  • 2
  • 19
  • 29
  • 4
    Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Taplar Nov 14 '18 at 23:17
  • `result` contains the promise object returned from the $.ajax call. It does not wait for the success to return the value. This is detailed futher in the duplicate post. – Taplar Nov 14 '18 at 23:17

0 Answers0