Atlas Callback, Timeout and Error Handler

Michael Schwarz on Wednesday, September 14, 2005

Because we are still missing some more docs about the Atlas Framework I have check the JavaScript files to give you a short overview over the use of how to write callbacks in the same way Ajax.NET Professional [1] is doing this. The JavaScript wrappers are generated on-the-fly, without any caching. If you have a look in the generated files you will see that they are similar to the generated files using Ajax.NET Professional [1]:

var WebService2 = { path: "/WebSite1/FritzWebService.asmx", HelloWorld:function(onMethodComplete, onMethodTimeout) { return Web.Net.ServiceMethodRequest.callMethod(this.path, "HelloWorld",{}, onMethodComplete, onMethodTimeout); } }

What is missing is the error handler and a context where you can add your own object that will be accessable in the handlers. If have checked the Atlas core JavaScript files and have written an example that is supporting all the handlers. At the moment you have to write these lines instead of adding the WebService.asmx/JS JavaScript include tag:

var WebService = { path: "/WebSite1/WebService.asmx", HelloWorld:function(_callback, _timeout, _error, _context) { return Web.Net.ServiceMethodRequest.callMethod(this.path, "HelloWorld",{}, _callback, _timeout, _error, _context); } }  

As you can see it is 100% the same as you are using already in Ajax.NET [1], you have only to add a _timeout handler. The handler methods are similar to Ajax.NET [1], too. The main difference is that they have an argument for each object instead of something like res.value:

var _callback = function(value, response, context) { alert("Callback:\r\n\r\nValue = " + value + "\r\nContext = " + context); }

var _timeout = function(context) { alert("Timeout:\r\n\r\nContext = " + context); }

var _error = function(response, context) { alert("Error:\r\n\r\nContext = " + context); }

Ok, let's have a look on the response object. The response object has several methods where you can get original values:

response.get_isActive response.get_body response.get_headers response.get_response response.get_timedOut response.get_url