[Mapbender-dev] JS exceptions

Marc Jansen jansen.marc at gmx.de
Thu Jan 11 06:28:36 EST 2007


Christoph Baudson schrieb:
> Hi there,
>
> when thinking about a return value for Mapbender JS exceptions, I 
> encountered the following problem. Maybe I'm missing a central, please 
> enlighten me:
>
> when I call the JS class Mb_exception, I'll fire the Ajax post 
> function.  The callback function is invoked, but it can't return the 
> value to the original caller, because that's in a different function.
>
> see http://www.mapbender.org/index.php/Talk:For_developers#return_value
>

Hey Christoph,

try this (untested as usual):

function Mb_exception(message) {
	return mb_ajax_post('../php/mb_js_exception.php', {text:message}, function(text, status){
		return (text == "true") ? true : false;
	});
}


note the first return before the function.

> Another solution might be to set a member variable of the class 
> (boolean $exceptionThrown); but again, because of the asynchronous 
> nature of Ajax, this would not work because I would want a return 
> value in the JS code rightaway.
>
> Any ideas?
>
> Christoph



More information about the Mapbender_dev mailing list