OK folks, after the silly go around with JQuery, AJAX and JSON, it's time to do it again with XML instead of JSON, though the problem might be the same. Excuse the bold font, I'm using it to distinguish comment from code.
The problem with JSON is sending quotes. Double quotes (") just choke it. Multiple single quotes do the same. So I decided to try XML to see if it can swallow it any better. This does not look good...
All I am trying to do is complete a circuit of using AJAX to send an XML message to a Web Method in ASP.Net, return an XML message and parse it. Right now I cannot send anything like XML.
The signature of the Web Method is:
public static string CatchAJAX_XMLRequest(Object data0)
Interestingly,if you send a simple (2 data member) JSON message to that, it picks up the value of the second argument.
Anyway, I would think you could do something like the code below, but it just gags. I would appreciate any suggestions. I've tried a number of things, but I am far from getting it to work. Thanks, Mike
function doAjaxXML_() {
var inData = "<?xml Version='1.0' encoding='UTF-16' ?><message error='' requestorID='1'><title>cd request</title><ContactCId>Farkle</ContactCId></message>"; // would love to send this alone, but nada
inData = "{'error':'none','data':'" + inData + "'}";
$.ajax({
type: "POST",
url: "jForm2.aspx/CatchAJAX_XMLRequest",
data: inData,
// Test 1
contentType: "application/json; charset=utf-8",
//contentType: "application/text; charset=utf-8", // this did something weird
//contentType: "application/x-www-form-urlencoded; charset=UTF-8", // this did nothing
dataType: "text",
//dataType: "xml",
//dataType: "json",
success: function (rdata) {
onXMLSuccess(rdata);
},
error: function (rdata) {
onXMLFailure(rdata);
},
});
}