Book Image

Lift Application Development Cookbook

By : Gilberto Tadeu Garcia Jun
Book Image

Lift Application Development Cookbook

By: Gilberto Tadeu Garcia Jun

Overview of this book

Developing secure web applications is one of the most important tasks developers have to deal with. With Lift, it is easy to create solid and formidable web applications as it is the most secure web framework available today. The View-First approach and being able to handle things as purely data transformation, makes working with Lift an exciting task. "Lift Application Development Cookbook" teaches you how to build web applications using this amazing framework. The book moves gradually, starting with the basics (starting a new project, submitting a form, and so on) before covering more advanced topics such as building a REST API and integrating your application with other technologies and applications. "Lift Application Development Cookbook" takes you on a journey of creating secure web applications. Step-by-step instructions help you understand how things work and how various elements relate to each other. You'll learn different ways to process a form, build dynamic HTML pages, and create an API using REST. You'll also learn how to work with relational and NoSQL databases and how to integrate your application with other technologies as well as with third-part applications such as Gmail and Facebook. By the end of the book, you will be able to understand how Lift works and be able to build web applications using this amazing and exciting framework.
Table of Contents (15 chapters)
Lift Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Invoking server-side functions from the client


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.

Getting ready

First of all, we will edit the index.html file.

  1. 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>
  2. 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...