It would be easier if you had a link to a test page or at least some code to
look at. Otherwise we can only guess what might be wrong.
 
Here is one possibility.
 
Note what you said here:
 
> ...by using gNewStoryID = response.STORY_ID, I was creating a

> global variable that could then be used in any function.

 
(emphasis added)
 
You are exactly right: First you create the global variable with the
assignment statement, and then you can use it.
 
The question is, when is then?
 
The global variable is created when your callback function executes.
 
These other functions where you're trying to use it: Are they being called
before the callback function executes, or after? If you put alert() or
console.log() calls wherever you set or reference your global variable, what
order do they appear in?
 
-Mike



  _____  

From: Rick Faircloth


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

 

Reply via email to