jMsAjax
 
Home of the jQuery Ms Ajax Plugin!

Update 29/07/2008: jMsAjax 0.2.1 out with date fix

jMsAjax is a simple wrapper with a few enhancements for the $.ajax function built into jQuery to support ASP.net. The plugin supports both Web Methods and Web Services for both GET and POST requests.

A few features of the plugin include:

  • All features available to $.ajax are still available for $.jmsajax
  • Safe parsing of the returned JSON object if dataType 'msjson' is used    (note: msjson must be used for correct date parsing)
  • Data can be sent to the server as a JSON object
  • Same syntax can be used for both GET and POST requests
  • The returned JSON object is ready to use without accessing the 'd' property
  • The method is separated from the URL

Supports minimum of ASP.net 2.0 with Ajax Extensions installed.
Usage
 
Defaults:
type: "POST"
data: {}
dataType: "msjson"
error: function to return the status and message

Basic Usage:
$.jmsajax({ 
   url: "jMsAjax.aspx",
   method: "getTime",
   success: function(data) {
      $("#div").html(String(data));
   }
});

Advanced Usage:
$.jmsajax({
   type: "POST",
   url: "jMsAjax.aspx",
   method: "getTime",
   dataType: "msjson",
   data: { date_in: new Date() },
   success: function(data) {
      $("#div").html(String(data));
   }
});
Download
 
Demo
 
Using the ajax call in the above advanced sample, I will send the current datetime to the server, add 5 days and replace the text below with the new time. The code behind looks like this:

[System.Web.Script.Services.ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[System.Web.Services.WebMethod]
public static DateTime getTime(DateTime date_in)
    return date_in.AddDays(5);
}

Click here to return the date in the div below

Result here


Links