I am calling a REST service method from AJAX.
$(document).ready(function () {
var xmml = getXmlLoginRequest();
var wsdlURL = getWSDL('search');
$.ajax({
type: "POST",
url: wsdlURL,
data: xmml,
contentType: "text/xml;charset=utf-8",
dataType: 'text',
success: function (result) {
debugger;
alert(" success" + result);
},
error: function (jqXHR, textStatus, errorThrown) {
debugger;
alert(" error" + "jq :" + jqXHR + "textStatus :" + textStatus + "error : " + errorThrown);
}
});
function getXmlLoginRequest() {
debugger;
var xml = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> \
<soap:Body> \
<search> \
<qry>svein </qry> \
</search> \
</soap:Body> \
</soap:Envelope>';
return xml;
}
function getWSDL(methodName) {
debugger;
var url = 'http:/MyURL/search.php?username=abc&password=def';
return url;
}
});
I am getting result as empty in success block. If I change dataType to text
, I get an exception in Failure block which says cannot parse NULL
.
Am I writing incorrect syntax? When I run the url on browser with method and its parameters, it gives proper result.