Recommended architecture for RESTful API
I'm trying to figure out what's the best way to use jQuery Mobile with PhoneGap to interact with a server.
So far I've read:
and haven't found a definitive answer. Or more likely am too lost to piece the information together.
Right now I've setup jQuery Mobile to:
- be multiple HTML pages
- before a page loads, it'll request JSONP data from the server and insert the data with the appropriate tags into the DOM
- refresh the list/page with the new list data
Things are working great since my first request is just a list of available "projects". The second request will require the client to tell the server to return a list of "lists" for a given "project" (or a list of "tasks" for a given "list" and etc.).
So I'm stuck on what architecture works best with jQuery Mobile. And then I'm stuck on what's the best way to implement it.
So the first part of the question: which URL structure to use when retrieving JSON data
Option 1: Rails-ish RESTful URLs (sorry I'm not sure if it's just considered RESTful or if it's the "Rails way")
Option 2: Basic GET with query parameters
[I'd prefer to use option 1 if possible since it's how Rails handle things normally.]
The second part of the question: does jQuery Mobile have something in place to keep track of the current states (project id, list id, etc). I've read bits and pieces of the HASH/AJAX navigation system and router plugins, but still haven't been able to wrap my head around it. From what I can understand it seems like these systems are meant to work on the server and not as an app on a phone, but doing that might give Apple heartache. pages. Of course I'm sure I'm lacking some basic understanding somewhere.
Sorry for the long post, but any advice will be greatly appreciated. And of course, if I'm missing some standard way of doing this, I'm more than ready to read up on it if you direct me where to look.
Thanks again for your time!
Oh BTW, here's how the models eventually play out:
"project" has many "lists"
"list" has many "tasks"