8
The easiest way to do this is to make the ajax call synchronous. Meaning in your f1 function setup the ajax call with async: false so that the function doesn't move on until the call is completed and the data returned.