473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with a closure and the return value

Hi,

i want to do something like that:

this.xmlhttp.onreadystatechange = return (function () {
if (myRequest.readyState === 4) {
return myRequest.responseText;
}
});

But i just get an Syntax error. How else could i return the responseText?

Greetings
Jul 23 '05 #1
2 2533


Börni wrote:

i want to do something like that:

this.xmlhttp.onreadystatechange = return (function () {
if (myRequest.readyState === 4) {
return myRequest.responseText;
}
});

But i just get an Syntax error. How else could i return the responseText?


Well with event based programming you can't return a value from the
onreadystatechange event handler, you need to somehow set that up
differently, the onreadystatechange event handler could call a function
and pass the responseText to it.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen wrote:

Well with event based programming you can't return a value from the
onreadystatechange event handler, you need to somehow set that up
differently, the onreadystatechange event handler could call a function
and pass the responseText to it.


Ok, thanx.

You are a real quick guy ;-)
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dave Benjamin | last post by:
Here are some more ideas for how to implement a statement-friendly code block syntax in Python. Hopefully more "Pythonic" (that is, of or pertaining to those features noticably reminiscent of...
27
by: Ted Lilley | last post by:
What I want to do is pre-load functions with arguments by iterating through a list like so: >>>class myclass: .... pass >>>def func(self, arg): .... print arg >>>mylist = >>>for item...
1
by: Victor Ng | last post by:
Is there a way to preserve the argspec of a function after wrapping it in a closure? I'm looking for a general way to say "wrap function F in a closure", such that inspect.getargspec on the...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
7
by: Csaba Gabor | last post by:
I feel like it's the twilight zone here as several seemingly trivial questions are bugging me. The first of the following three lines is a syntax error, while the last one is the only one that...
0
by: Gerard Brunick | last post by:
Consider: ### Function closure example def outer(s): .... def inner(): .... print s .... return inner .... 5
11
by: Huayang Xia | last post by:
What will the following piece of code print? (10 or 15) def testClosure(maxIndex) : def closureTest(): return maxIndex maxIndex += 5 return closureTest()
7
by: abs | last post by:
Hi everyone. Please, check my test code here: http://skocz.pl/jstest . The trouble is that no matter which span element I click, it alerts '3' and I'm wondering why not '1' for the first span,...
2
by: jman | last post by:
for ( var i = 0; i < div.firstChild.childNodes.length; ++i ) { var marker = new Object(); marker.iii = i; sys.addListener( marker, "click", function() { alert(marker.iii); }); }
3
by: disappearedng | last post by:
Hi everyone I am currently reading a book, and I don't seem to under the author, (Crockfold) when he says this: //Bad examples var add_the_handlers = function(nodes){ var i; for (i = 0; i <...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.