KevySaysBeNice
[H]ard|Gawd
- Joined
- Dec 7, 2001
- Messages
- 1,452
Hi all!
I have a simple best practice question. This will probably seem very trivial and stupid, but I'm honestly not sure about the best way to do this:
Say I have a web application that tracks tasks, like a todo list web application. I have a bunch of lists that have titles like "Things to Do" (etc), and my web application "front page" has this list, which shows the titles. Clicking on a title brings you to a page of the tasks for that list. In a DB, each list has a unique ID. The URL when you're editing a task would look something like:
http://www.domain.com/edit-list/9/Things-to-Do
(where 9 is the ID of the list)
I have a "save list" button, that when clicked saves any changes I made to the list. I want to make an AJAX call to save the list. SO, I make a JSON object with the change I made and pass that in, BUT (Now, here is the question) I also need to pass in the ID of the list.
I could:
1) use JS to parse/pull the ID of the list from the URL (which would require client side parsing and would break things if I changed how the URLs were written)
2) Add a hidden form field somewhere with the list ID (which may/may not be a bad practice?)
3) Some other option
So, maybe a lot of typing for a simple question, but what would you do?
Thanks guys!
I have a simple best practice question. This will probably seem very trivial and stupid, but I'm honestly not sure about the best way to do this:
Say I have a web application that tracks tasks, like a todo list web application. I have a bunch of lists that have titles like "Things to Do" (etc), and my web application "front page" has this list, which shows the titles. Clicking on a title brings you to a page of the tasks for that list. In a DB, each list has a unique ID. The URL when you're editing a task would look something like:
http://www.domain.com/edit-list/9/Things-to-Do
(where 9 is the ID of the list)
I have a "save list" button, that when clicked saves any changes I made to the list. I want to make an AJAX call to save the list. SO, I make a JSON object with the change I made and pass that in, BUT (Now, here is the question) I also need to pass in the ID of the list.
I could:
1) use JS to parse/pull the ID of the list from the URL (which would require client side parsing and would break things if I changed how the URLs were written)
2) Add a hidden form field somewhere with the list ID (which may/may not be a bad practice?)
3) Some other option
So, maybe a lot of typing for a simple question, but what would you do?
Thanks guys!