jQuery and Ajax.NET Professional (AjaxPro)

Tags: AJAX, Ajax.NET, ASP.NET, JavaScript, jQuery

jQuery is a fast, concise JavaScript library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript, but it can be only used on the client-side JavaScript code. That means you need a framework on the server-side code if you want to add Ajax interactions to your web pages.

Ajax.NET Professional (AjaxPro) is one of the right answers that you can use if you are using the Microsoft .NET Framework 1.1/2.0 on the server-side code, doesn't matter which .NET language you are using.

AjaxPro is very easy to use with other JavaScript frameworks. You simple remove the AjaxPro.Utility.RegisterTypeForAjax(typeof(...)); line in your Page_Load and replace the Ajax requests with other frameworks.

jQuery is doing the job very good, you simply have to write following code if you want to run an asynchronous call to a HelloWorld method in YourNamespace.Test class which will return a copy of the inpust string s.

$.ajax({
    type: "POST",
    url: "/ajaxpro/YourNamespace.Test,App_Code.ashx",
    data: '{"s":"Michael Schwarz"}',
    beforeSend: function(xhr) {
        xhr.setRequestHeader("X-AjaxPro-Method", "HelloWorld");
    },
    success: function(s) {
        var o = null;
        eval("o = " + s + "*/");
        alert(o);
    }
}); 

The special eval statement I'm using is because on some web servers we got strange results that added some extra text to the JSON output which ends in an JavaScript error (like "http 100 Continue").

By the way jQuery can do more: CSS handling, event handling, DOM properties,... have a look at the docs to read more.

No Comments