In the previous recipe, we learned how to create JavaScript functions/code on the server and how to invoke/trigger those codes from the client. This is very useful, however, it's not enough, since there are times when we need to do the opposite. In other words, what do we do when we need to call a function on the server side using JavaScript? The solution is to use Ajax. In this recipe, we'll learn how to use Ajax and Lift's JavaScript abstraction layer to create a function on the server side and call it from the client side.
First of all, we will edit the index.html
file.
Invoke the snippet that will create the Ajax function that we are going to call, using the following code snippet:
<span class="lift:JsCommand.jsFunction"></span>
Add a combobox containing some names and a button, as shown in the following code:
<div> <select id="person"> <option value="Carly">Carly</option> <option...