Until recently, when I write ajax call, always write like below:
"post""json""someurl"
And repeat everywhere... Until some day: so much redundant code!
Fournately, the "ajaxwrapper" tool can resolve this problem. ^. ^
By using "ajaxwrapper", the code will be changed like this:
a2d.core.ajax.ajaxwrapper("ajaxDefinationId", { userId: 100 }, }).call();
I believe you 'v found something missed --> we shoshould define "ajaxDefinationId" first, like below:
a2d.core.ajax.ajaxwrapper.setup.add({ id: "ajaxDefinationId", method: "post", url: "testurl.aspx" });
Explain-core code:
a2d.core.ajax.ajaxwrapper = defaultConfig = realConfig = setupConfig = ajaxCall = "json"( () { kxtx.core.exception("ajax error"
Code is simple. First, it search ajax's global defination & current definatio, and then invoke jquery's ajax method.
Let's look error handler:A2d. core. exception. service. takeoverFunction,This function can add a wrapper on a function. When an error throw in function,TakeoverFunctionWill catch it, and process it. See below:
A2d. core. exception. service. takeoverFunction = newHandler = 012345678910 (ex "a2d. core. exception: occurred" "unknown exception type"
Code is still simple. Core code is "try/catch" -->A2d. core. events. service. publish ("a2d. core. exception: occurred", ex );
AhHa, finally, we found the error was published by a2d framework. Depend on this mechanism, the concrete impl be decopouled by pub/sub pattern, we can subscribe this event flexible.
The tool has been integrated into A2DFramework.