Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
gloabal variable value not assigning
Sridhar Ranganthan
Ranch Hand
Posts: 36
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
HI,
global variable value is not assiging during asynchronous call.
consider the below ex
var count=0; function myfun() { alert(count) // count 0 serviceCall() alert(count) //Here i want callback method count value ,but getting 0.Why? how to achieve that. } function callback(status,app) { count=app.count; alert(count); } function serviceCall() { app= appmiddlewareinvokerAysnc(inputparam,callback); }
Thanks,
sri.R
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Because the request is asynchronous. Line 10 executes after the request is made but it's not going to wait for the request to complete so the variable has yet to be updated.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Accessing a variable outside of a javascript function?
Select All and Clear All implementation in JSF
Need Help with Ajax.
[Ajax] if callback function has parameters?
auto-increment no.(sequential no.) in javascript?
More...