That's not what the code snippet you found does (it actually doesn't do much of anything). There's several different ways to achieve this in Visualforce, including:
- Visualforce Remote Objects, for simple data access only.
oncomplete attribute and rerender Visualforce page elements.
oncomplete handler and rerendering of Visualforce page elements.
Which of these tools you should be applying depends completely on your actual objective here, and may require you to make significant changes to how you understand the order of operations between the client and server code elements.