I am trying to call an asmx service using jQuery Ajax.
POST /YderWS.asmx HTTP/1.1
Host: localhost
Content-Type: text/
jQuery.ajax()
issues generic HTTP requests for any type of "web service", not just .NET web services. You'll want to add a SOAPAction request header and pass the entire SOAP envelope as POST data:
$.ajax({
type: 'POST',
url: servicename + "/" + functionName,
contentType: 'text/xml; charset=utf-8',
headers: {
SOAPAction: 'http://scandihealth.com/iwebservices/HentKommuner'
},
data: 'string string string ',
success: successFn,
error: errorFn
});
If you're using jQuery < 1.5, you'll need to use beforeSend
to set the SOAPAction request header.
You can find the documentation for jQuery.ajax()
at http://api.jquery.com/jQuery.ajax/.