I'm encountering an issue when attempting to send XML via an ajax call to my Webmethod (C# Webforms):
Previously, I successfully tested the ajax call with JSON and was able to send JSON to the Webmethod.
Although the response status code returns as 200, it fails to trigger the debugger on the webmethod whenever I try to send XML.
Could someone kindly point out what mistake I might be making?
JavaScript:
var xmlData = '<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Dont forget me this weekend!</body></note>';
$.ajax({
type: "POST",
url: "/App/drawIOjs/draw.aspx/GetDocument",
data: { xml: xmlData },
contentType: "text/xml; charset=utf-8",
dataType: "text",
success: function (response) {
debugger;
alert(response);
},
failure: function (response) {
// handle failure here
debugger;
alert(response);
}
});
Webmethod:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public static string GetDocument(string xmlData)
{
string testing = xmlData;
return "This is a string from the Code behind";
}