Quote:
function Init()
{
OrderData=GetOrder()
}
alert(OrderData)//This alert returns "undefined"
|
Well it would, seeing as how you set the value of OrderData to be a function NOT the value from the function. Because the function does NOT return a value.
you are missing the return xmlHttp.responseText; from the AJAX call
Your code is a bit of a mish mash in rather poor VB style code by trying to use a global scoped variable to pass values instead of allowing the function to actually return a value.
javascript & JScript are rather less forgiving on sloppy code than VB/VBScript is.
to use the code syntax you had, the Init() call should be
Code:
function Init()
{
GetOrder()
alert(OrderData)
}
Using a globally scoped variable for passing values between sub / function calls is poor practice and will lead to more and more problems as your application grows.
If you need a global value, define as a read only property, it is much safer if your code cannot accidentally redefine it or overwrite the value.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|