$.getJSON return/scope issue? [duplicate]
问题 This question already has answers here : How do I return the response from an asynchronous call? (36 answers) Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference (6 answers) Closed 2 years ago . This is my code and the alert always displaying null as value in item function make_recent_item(recent_counter){ var json_path_popular= 'http://localhost/complaints_old/webservice/get_new_complaints' + '?recent_counter='+recent_counter; var item=null; $