views:

1116

answers:

4

Under what circumstances would you use MicrosoftAjax over jQuery in an ASP.NET MVC application?

According to Scott Cate in this podcast Object Oriented AJAX with Scott Cate MicrosoftAjax is good for sending and retrieving data to and from the server. And jQuery is good for manipulating your data via the DOM once it arrives at the client. Yet, with a simple form plugin for jQuery you can send and retrieve data with jQuery quite easily. Often with a single line of code.

So I'm wondering what the difference is between MicrosoftAjax and jQuery within ASP.NET MVC?

+10  A: 

Go with jQuery - even Microsoft has seen the error of their ways. The next version of Visual Studio will include jQuery and support it with intellisense. You're also entirely correct regarding the simple plugin. MS Ajax, while sometimes easier to work with initially, is slow and bloated.

Mike Robinson
+1. jQuery rocks !!
Perpetualcoder
-1 for incorrect information. Microsoft includes both jQuery and MsAjax in the _current_ MVC project templates.
Daniel
MVC template yes, Visual Studio no.
Mike Robinson
What incorrect information?
Justice
A: 

jQuery is lighter-weight, easier to integrate into standard javascript functions, and has great community support. MS Ajax is heavy, but I suspect they are rewriting everything AJAX.

Ash Machine
+2  A: 

I have tried to use both more or less side by side.

The builtin ajax helpers works fine.

But jquery has a smaller footprint and is more transparent in use.

And when using the ajax helpers I get immediate results but no sense of what goes on behind the scenes

Besides If you have to bridge over into jquery in order to extend your ajax scenario, you might as well start there.

Christian Dalager
A: 

Just be sure to use the jQuery.ajax function and not jQuery.get - its more verbose, but vital for error handling.

Don't skimp on error handling code just because jQuery.get() is easier. It may work on your tests, but you need some kind of error handling for the many cases it wont work.

I'm really not sure why get doesn't have error handling, but here's a quote from the jQuery documentation for get:

This is an easy way to send a simple GET request to a server without having to use the more complex $.ajax function. It allows a single callback function to be specified that will be executed when the request is complete (and only if the response has a successful response code). If you need to have both error and success callbacks, you may want to use $.ajax.

Simon_Weaver