0

ASP.NET 1.1 Web Services and jQuery

Posted March 5th, 2010 in asp.net, jQuery, javascript, webdev by Alex Barberis

While working on a project today I figured out how to use jQuery’s $.ajax functionality to consume an ASP.NET 1.1 web service. I was always under the impression that this wasn’t possible. However, this is quite easy. By default an ASP.NET 1.1 web service will accept an HTTP GET, HTTP POST, or HTTP SOAP. Calling a 1.1 web service is as easy as:

$.ajax({
	type: "POST",
	url: 'PathToYourService.asmx/FunctionName',
	data: 'foo1=value1&foo2=value&foo3=value',
	dataType: "xml",
	success: function(xml) {
		//do something with your data
	}
});

Replace the data variables with your service parameters and you should be all set. jQuery makes parsing all that XML really easy as well.

Leave a Reply