views:

777

answers:

4

I used jQuery exclusively on my last project to do all my AJAX calls. I used both $.ajax and $.getJSON calls to return data to the page. However, I see a ton of examples online using jQuery to handle UI and data formatting, but using ASP.NET AJAX to actually perform web service calls and retrieve data. Is it more efficient to use ASP.NET AJAX to retrieve data for AJAX calls? Does it perform better than jQuery?

+7  A: 

I don't think it will make too much difference whether you use ASP.NET Ajax or jQuery. What might make difference is what data is returned and what format it is in i.e. XML, HTML or JSON.

For example, it might be more efficient to return a lightweight JSON object from an Ajax call rather than a big XML document: you can always monitor the size of the Ajax response using Firebug or something similar.

You'll probably have to judge each scenario on it's own merits though.

Ian Oxley
+1  A: 

I have been wondering this same thing myself. When MS announced JQuery support going forward I was wondering about the "recommended" approach for doing things where the two frameworks overlap (ie: making async calls to the server) going forward since there is some overlap between the two libraries.

I think the biggest efficiency gain you will get is obviously in the data transport you are using (json vs. xml) but I am not as familiar with JQuery's implementation of $.ajax and $.getJSON versus using something like Sys.Net.WebServiceProxy to call the server. One nice thing about the asp.net ajax client stack is the hooks for network calls, we used this for creating a base behavior that can inspect the response from the server and do something specific (ie: looking for certain HTTP Status codes).

mdarnall
what about the overhead of including both libs?? IMO stick with jQuery.
redsquare
A: 

I thought that ASP.Net's libraries were adapted to use jquery... http://www.aspcode.net/ASPNET-and-JQuery-first-example.aspx

If true, it would mean the two are linked in speed. Although jQueries libraries are likely updated quicker.

SuperRoach
The ASP.NET libraries haven't been updated to use jQuery. That article is really just talking about how you'd use jQuery to play with the HTML - it was written in 2006, MS only started supporting it in Oct/Nov 2008.
Zhaph - Ben Duguid
+5  A: 

i used Ajax Control Toolkit from microsoft quite extensively for 2 years before i switched to jQuery and in my experience i think jquery ajax calls are much more light weight, efficient compared to the ajax control toolkit libraries. besides that the efficiency ofcourse depends on the data that you send & receive via your ajax calls.

you can add custom HTTP Status codes in jQuery ajax calls as well to capture any errors on the server and returning the appropriate response.

Vikram