Js calls object properties and encounters a very strange thing.

:


ajaxresonseJSONundefined

A piece of meat is right in front of you, but you don"t have the heart to hit people.

Mar.14,2021

classmate, do you know async?


classmate, do you know asynchronous?

return result to console.log (result) ?


when you use the getJSON method


to execute console.log (), your request may not have been executed, that is, the data has not yet been returned


execute ajax first. Of course, undefined


ajax is asynchronous, so it is not strictly from top to bottom


juvenile, asynchronously?


see that the object you print supports then,

var token = $.ajax({
    url: "/get_token", success: function (result) {
        return result
    }
}).then(function(result){
    return result
});

console.log(token.resonseJSON);

?            
Menu