Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How can I return that values

Reply
Thread Tools

How can I return that values

 
 
Mariano
Guest
Posts: n/a
 
      01-14-2008
Then, I have this script:

function mainFunction(src, type) {
// ...
if(XMLHttpRequestObject) {
XMLHttpRequestObject.open(type, src, true);
XMLHttpRequestObject.onreadystatechange = function(){
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {
var xmlDocument = XMLHttpRequestObject.responseXML;
var returnValue = calling(); //<==FUNCT
}
}
XMLHttpRequestObject.send(null);
}

}

function calling() (see the //<==FUNCT marker), when executed, return
a boolean value. Now since this function, is never called directly,
but always from mainFunction() function [and through anonymouse
function], I need that mainFunction return at the end the same value
of calling() execution [returnValue]. How can I do It?
Thanks.
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-14-2008
Mariano wrote:
> function mainFunction(src, type) {
> // ...
> if(XMLHttpRequestObject) {
> XMLHttpRequestObject.open(type, src, true);
> XMLHttpRequestObject.onreadystatechange = function(){
> if (XMLHttpRequestObject.readyState == 4 &&
> XMLHttpRequestObject.status == 200) {
> var xmlDocument = XMLHttpRequestObject.responseXML;
> var returnValue = calling(); //<==FUNCT
> }
> }
> XMLHttpRequestObject.send(null);
> }
>
> }
>
> function calling() (see the //<==FUNCT marker), when executed, return
> a boolean value. Now since this function, is never called directly,
> but always from mainFunction() function [and through anonymouse
> function], I need that mainFunction return at the end the same value
> of calling() execution [returnValue]. How can I do It?


You can't. Since your HTTP request is handled asynchronously (as indicated
by the `true' value as third argument of XHR:pen()), the execution context
of mainFunction() is probably left before the event listener is called.

What *exactly* are you trying to do?


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
 
Reply With Quote
 
 
 
 
Mariano
Guest
Posts: n/a
 
      01-14-2008
On 14 Gen, 22:23, Thomas 'PointedEars' Lahn <(E-Mail Removed)>
wrote:
> Mariano wrote:
> > function mainFunction(src, type) {
> > // ...
> > if(XMLHttpRequestObject) {
> > XMLHttpRequestObject.open(type, src, true);
> > XMLHttpRequestObject.onreadystatechange = function(){
> > if (XMLHttpRequestObject.readyState == 4 &&
> > XMLHttpRequestObject.status == 200) {
> > var xmlDocument = XMLHttpRequestObject.responseXML;
> > var returnValue = calling(); //<==FUNCT
> > }
> > }
> > XMLHttpRequestObject.send(null);
> > }

>
> > }

>
> > function calling() (see the //<==FUNCT marker), when executed, return
> > a boolean value. Now since this function, is never called directly,
> > but always from mainFunction() function [and through anonymouse
> > function], I need that mainFunction return at the end the same value
> > of calling() execution [returnValue]. How can I do It?

>
> You can't. Since your HTTP request is handled asynchronously (as indicated
> by the `true' value as third argument of XHR:pen()), the execution context
> of mainFunction() is probably left before the event listener is called.
>
> What *exactly* are you trying to do?
>
> PointedEars
> --
> Use any version of Microsoft Frontpage to create your site.
> (This won't prevent people from viewing your source, but no one
> will want to steal it.)
> -- from <http://www.vortex-webdesign.com/help/hidesource.htm>


then. through mainFunction() i call calling(), this is raised up by
onkeyup on an input box. I do this sort of thing 3 times, username,
password and email field. I need to understand return of these 3
function calling, so I can understand if realize the form action or
show an error.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Re: Unpack less values from function's return values Chris Rebert Python 1 05-28-2009 02:47 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
Can you persist table cell values like you can do with form field values? Richard Dixson ASP .Net 1 05-18-2004 03:47 AM



Advertisments