The decision is up to you really because no way is "wrong" but always remember with things like that if they are going through Ajax to check the id is numeric and validate it in the backend. Its really easy to hack up the DOM Cookies tend to more secure in a sense so it might be more sensible to store it in a cookie. Or query on an API for that information with Ajax using a REST method.
~Sent from my HTC Touch Pro~ -----Original Message----- From: Vik <v...@mindspring.com> Sent: Wednesday, April 22, 2009 3:12 AM To: jQuery (English) <jquery-en@googlegroups.com> Subject: [jQuery] Re: Communicating Info from Server to Javascript, Prior to Ajax Calls? Thanks for the feedback, Jordon. Let's say it's not something that belongs in the cookie. Then is it correct to do it via a hidden field? On Apr 19, 2:59 pm, "Jordon Bedwell" <jor...@envygeeks.com> wrote: > If you use PHP then it's better to have it output the userID as a variable > already inside of JavaScript to save the extra code, or to set it as a > cookie, as a matter of fact, if you use Expression Engine, WP or most any > other major CMS, there is a cookie already set with that info so you can > just pull it from there. > > -----Original Message----- > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On > > Behalf Of Vik > Sent: Sunday, April 19, 2009 3:40 PM > To: jQuery (English) > Subject: [jQuery] Communicating Info from Server to Javascript, Prior to > Ajax Calls? > > Let's say I want my javascript to know some info, e.g. the username of > the user, and I'd like to communicate it prior to any Ajax calls. So > far I've been storing the info in a hidden field that jQuery can > access via an id. Is this the correct approach? > > Thanks in advance to all for any info.