views:

240

answers:

2

hi, i was wondering if there is any significant difference between consuming .asmx services with asp.net ajax calls - serviceName.method(param,...) or with the jquery $.ajax call. I'm currently using the asp.net ajax which seems simpler but i get the js proxy file as well. i don't mind getting my hands a little dirty if using jquery is more effective. thanks.

A: 

They'll both work, however asp.net ajax has the built in ability to consume asmx services, which will save you the trouble of parsing out the data.

jQuery, fortunately has the ability to make itself work on a page where another javascript framework already lives using its "NoConflict" option. So you could actually use both asp.net ajax (for the asmx services) AND jQuery for everything else if you wanted to.

free-dom
+1  A: 

The speed of the call itself isn't going to vary between MicrosoftAjax.js and jQuery. Using jQuery does allow you to avoid the extra overhead of downloading the ASMX's JavaScript proxy though. If you're not using ASP.NET AJAX for anything else, it also allows you to avoid the overhead of downloading MicrosoftAjax.js.

If you do want to use jQuery to call the service directly, it's not very difficult. This is a basic example of how to do it: http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

Once you understand that basic form of the call, this is a more refined usage that isolates you from a breaking change in ASP.NET 3.5+ and allows you to leverage the browser-native JSON parsing in newer browsers: http://encosia.com/2009/07/21/simplify-calling-asp-net-ajax-services-from-jquery/

Dave Ward

related questions