Is it posible to use ajax respone outside of it?
问题 Any way of using the data_response outside the $.post() ? This is part of the code I use: $.post('do.php', { OP: "news_search", category: cat_id }, function(data_response){ var response = data_response; //I need to access this variable outside of $.post() } }, "json"); console.log(response); //response is not defined, is what I get for now UPDATE Is there no way of getting that response available globally? 回答1: No; $.post executes asynchronously, so when you call console.log , the AJAX