I assume you are using jQuery for your Ajax call. If so, what you want to do is to pass a function to newAction, that can be used in the .done() resolution function of the Ajax call. This function can perform whatever actions need to wait until the response is received.
The .done() callback is in the function newActivity at line 27, so newActivity is already executing before the ajax call is even made.
At line 4 you make the ajax call, and when the response returns, the function passed to .done() at line 27 is executed, with the response data in parameter responseJson2a. It is within this callback function that any code that needs to wait for the response must be placed.