title: Using jquery mobile and json in Rails
body: <p>I have a simple rails app the displays a list of items and i want to create a native mobile app using jquery mobile and the items would be featched from the main site.
  my controller is</p>
  
  <pre><code>class ListsController &lt; ApplicationController
  
    respond_to :json
  
    def index
      @lists = List.all
      respond_with(@lists)
    end
  
    # ...
  end
  </code></pre>
  
  <p>then in my native mobile app i have this in my index.html page</p>
  
  <pre><code>$.ajax({
      url: "http://localhost:3000/lists",
      dataType: "json",
      type: "GET",
      processData: false,
      contentType: "application/json"
  });
  </code></pre>
  
  <p>this data is fetched and i would like it to be appended in the jquery mobile template inside the li tab. How can i do this using jquery. Thank you</p>
  
  <pre><code>&lt;!DOCTYPE html&gt; 
  &lt;html&gt; 
      &lt;head&gt; 
      &lt;title&gt;Page Title&lt;/title&gt; 
  
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; 
  
      &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" /&gt;
      &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  
  &lt;body&gt; 
  &lt;div data-role="page"&gt; 
      &lt;div data-role="header"&gt;
            &lt;h1&gt;Simple test app&lt;/h1&gt;
          &lt;/div&gt; 
      &lt;div data-role="content"&gt;
           &lt;ul&gt;
            &lt;li&gt;(content appends here)&lt;/li&gt;
           &lt;/ul&gt;
          &lt;/div&gt; 
      &lt;div data-role="footer"&gt;
            &lt;h4&gt;test app&lt;/h4&gt;
          &lt;/div&gt; 
  &lt;/div&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the json output example is below</p>
  
  <p><img src="https://i.stack.imgur.com/XmTrZ.png" alt="json output"></p>