O'Reilly logo

jQuery Mobile Cookbook by Chetan K Jain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fetching data using GET

This recipe shows you how to use an Ajax GET request and fetch data from a server. In this recipe, the server sends back soccer scores to a GET request from a Soccer League Scores form.

Getting ready

Copy the full code of this recipe from the code/05/get-request sources folder. This code can be launched using the URL http://localhost:8080/05/get-request/main.html. To try out this recipe you will need to launch the simple nodejs web server that is shipped along with the source code of this book. Launch the server by using the following command:

node jqmserver.js

How to do it...

  1. In main.html, add the following code to create a form:
    <div id='scores' data-role='fieldcontain'>
     <form id='scoreform' action='/getScores' method='get'> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required