Archive for the ‘Mootools’ Category

Ajax.NET Professional with Mootools (part 2)

This is an update to my original post.  That version was a preliminary attempt and should not be used in production.

The MootoolsTypeJavaScriptProvider is a compatibility layer between AjaxPro and Mootools

The provider now supports most of the native AjaxPro javascript functionality.  The idea is to maintain as much compatibility as possible with the original AjaxPro javascript library to eliminate the need for changes to existing code.

Download Version 1.6 Binaries
Download Source Project

Tested on Internet Explorer 6 & 7, Firefox 1.5 & 2.0, Opera 9.

Working AjaxPro javascript options:

  • Fully compatible method signature for invoking calls from script: MyServerClass.Method(<arguments…>, callback, context, onError);
  • Synchronous requests (no change in syntax)
  • Compatible with most Global AjaxPro options & event handlers:
    • AjaxPro.onLoading
    • AjaxPro.onError
    • AjaxPro.onTimeout
    • AjaxPro.onStateChanged
    • AjaxPro.timeoutPeriod

Not working:

  • Support for any IE version less than 6 (this is a requirement for Mootools in general)
  • Tokens (they are implemented on the client, but when you set AjaxPro to RenderJsonCompliant, it stops emitting/checking the token data required.  An modified build of AjaxPro is required to fix this)
  • AjaxPro.cryptProvider
  • AjaxPro.queue (see below)
  • Using IFrames instead of XmlHttpRequest

Additions / Breaking Changes from default AjaxPro javascript lib:

  • AjaxPro.toJSON simply references Mootools Json.toString.  The resulting JSON string may be different.
  • AjaxPro.queue does not work, however you can toggle request queuing by using the AjaxPro.queueRequests flag I’ve added (defaults to true).  This is just a wrapper for Mootools autoCancel property which handles the actual request queue.
  • Aborting asynchronous requests uses different syntax.  To abort a request, use the following:
    var req = MyServerClass.Method(...); req.cancel();

    This is using the native cancel function from the Mootools XHR class.


  • Copy the mootools-core.js file into your project
  • Reference the Ifw.AjaxNet.dll assembly in your project
  • Adjust the AjaxPro web.config options in ajaxNet/ajaxSettings:
<scriptReplacements> <file name="core" path="~/res/js/ajaxpro/mootools-core.js"/> <file name="prototype" path=""/> <file name="converter" path=""/> </scriptReplacements> <providers> <typeJavaScriptProvider type="Ifw.AjaxNet.MootoolsTypeJavaScriptProvider, Ifw.AjaxNet"/> </providers> <oldStyle> <renderJsonCompliant/> <renderDateTimeAsString/> </oldStyle>