I need assistance with the following code:
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: location,
data: JSON.stringify(ajaxData),
dataType: 'xml',
success: callback,
error: function (x) { alert(JSON.stringify(x)) }
});
This method is implemented in a .aspx.vb file:
<Web.Services.WebMethod(EnableSession:=True)>
<Script.Services.ScriptMethod(ResponseFormat:=Script.Services.ResponseFormat.Xml)>
Public Shared Function WebMethod(ByVal arg As String) As String
Dim xml As New Text.StringBuilder
Using writer As XmlWriter = XmlWriter.Create(xml, New XmlWriterSettings With {.Encoding = New Text.UTF8Encoding(False)})
'build XML and return it
End Using
End Function
While this code works as intended in IE and Firefox, it encounters an issue in Chrome where the error handler triggers. The responseText property of the request object contains the expected XML along with a varying number of \u0000
s. I suspect there might be an issue with encoding, but I haven't been able to pinpoint it yet. Here's an example of how the response appears in the Chrome visualizer: