I invoke a WebService method via jQuery
.js code
$.ajax({
url: '/ms.asmx/se2',
data: {},
success: function (result) {
alert(result);
},
dataType: 'text'
});
.asmx method
[WebMethod]
public string se2()
{
return "OK";
}
the result is
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">OK</string>
How to show only that XML content – OK – instead the XML code ?
jQuery has a function to parse XML:
$.parseXML(http://api.jquery.com/jQuery.parseXML/). In addition, if you pass ‘xml’ todataType, jQuery will automatically parse it as xml.So: