This might be a very basic question, but I’m getting a bit confused. I’m working on a small web app which is based on 3-5 pages, mostly list based, with a couple pages being based on a single “object” of some data. I want to create basic templates for these pages and fill them with data from my database. I’m using jQuery Mobile.
My question is – if I use some method of retrieving the data via JSON, which is better? I guess it would be like this:

Edit: As a third option, what if I did this: index.php gets the json from data.php and just outputs it as a JSON object, which I can use jQuery to fill the data into the page, and then only use getJSON if that object isn’t defined?
Option 2 is really your best bet from a separation of concerns perspective. If you ever decide to change your backend implementation (i.e.: RoR or ASP.NET for example), you should not need to change your client-side code.
Option 1 will indeed give you a marginal performance benefit over Option 2, and is a good option if you KNOW that the backend implementation will never change.