[Mapbender-dev] JS exceptions

Marc Jansen jansen.marc at gmx.de
Thu Jan 11 07:27:21 EST 2007


Hey Chrisptoph,

you've got me stuck to this now!


Christoph Baudson schrieb:
> Hi Marc,
>
> thanks for your fast reply.
>
>> 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;
>>     });
>> }

The cleanest approach would be to extend Mb_exception with an additional 
and optional parameter: the callback function!

function Mb_exception(message, callbackfunction) {
  // make callback optional without raising an error
  if (typeof callbackfunction != 'function') {
     callbackfunction  = function() {};
   }
   // always pass in callback function
   mb_ajax_post('../php/mb_js_exception.php', {text:message}, 
callbackfunction );
}

(The wrapping stuff should than be updated as well, not sure about this, 
but you'll get the idea)

one could the call it this way:

var myCallbackAfterSuccessfullLogging = function (text, status) {
  if (text == 'false') {
    alert('something has gone terribly wrong, and we could not even log 
it!');
  } else if (text == 'true') {
    alert('something has gone terribly wrong, but the error at least 
could be logged');
    // put the critical functions within this block, and you're done.
  }
}

Mb_exception('This is the error message', 
myCallbackAfterSuccessfullLogging);


More information about the Mapbender_dev mailing list