Hi, Michael and thanks for the reply…
That helps some, but something I realized after I posted confuses me even more. I noticed the global variable I set, gNewStoryID, did show up when I tried to used it in another function on the same page, *even while throwing the error at the same time!* Why would the gNewStoryID variable show up in a different function that uses the statement “$(‘#newStoryTitleID’).empty().append(gNewStoryID);” and display with the correct value on-screen, then immediately throw an error that “gNewStoryID is not defined” ??? I was passing the variable around between functions using function xyz(response), but thought I’d make it simpler by creating global variables. But the outcome is confusing. Concerning the static or class variables…do those function more like session variables that are available throughout all js code on a page, or even throughout an application? Thanks for the tutoring! Rick From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Michael Lawson Sent: Monday, April 06, 2009 1:23 PM To: jquery-en@googlegroups.com Cc: jquery-en@googlegroups.com Subject: [jQuery] Re: Trying to understand how to use global variables... Hi Rick, A global variable is available throughout a single instance of the script. For example, If I have a global variable called foo, I can access it in any function within the same script. However, If my application changes pages, I will lose the values in those globals, or even the definitions themselves. Does that help your understanding any? Session variables are a better example of static, or class variables than globals. cheers Michael Lawson Content Tools Developer, Global Solutions, ibm.com Phone: 1-828-355-5544 E-mail: mjlaw...@us.ibm.com 'Examine my teachings critically, as a gold assayer would test gold. If you find they make sense, conform to your experience, and don't harm yourself or others, only then should you accept them.' Inactive hide details for "Rick Faircloth" ---04/06/2009 01:17:24 PM---I’ve read up on the subject, but my application is show"Rick Faircloth" ---04/06/2009 01:17:24 PM---I’ve read up on the subject, but my application is showing that my understanding has gaps. From: "Rick Faircloth" <r...@whitestonemedia.com> To: <jquery-en@googlegroups.com> Date: 04/06/2009 01:17 PM Subject: [jQuery] Trying to understand how to use global variables... _____ I’ve read up on the subject, but my application is showing that my understanding has gaps. If I have an ajax function that in the returned “response” exists a value called “response.STORY_ID” and I used the statement in the success section of the ajax function, gNewStoryID = response.STORY_ID, and then alert(gNewStoryID), I do get the property ID returned in the alert. Now I want to use that variable, gNewStoryID, in other functions. My understanding was that, by using gNewStoryID = response.STORY_ID, I was creating a global variable that could then be used in any function. However, when I try to use the gNewStoryID in another function, for instance, $(‘#newStoryIDSpan’).empty().append(gNewStoryID); I get an error stating “gNewstoryID is not defined”. Where is my understanding in complete? I was think that a global javascript variable would be available through the application as is a ColdFusion session variable. Thanks for helping me understand! Rick --------------------------------------------------------------------------------------------------------------------------------------- "It has been my experience that most bad government is the result of too much government." - Thomas Jefferson
<<image001.gif>>
<<image003.png>>
<<image004.png>>