This should be something easy to look up, but any related documentation I see fails to work in this case. Let's say you have a response coming back from a web service call with the following XML:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">Hello, World! str=1</string>
I just want to be able to extract the value - Hello, World! str=1 - without having to use string.replace() or anything else like that. If the XML were stored in a variable called response, and if the following code were called:
alert(response.documentElement.nodeValue)
"undefined" is what shows up. What the heck? I just want to get a string or any sort of ordinary primitive out of a web method (I'm not using JSON or anything), but documentation on how to do this is being difficult to find. How do you do this? Thanks!
EDIT: Here's the code:
<WebMethod()> _
Public Function HelloWorld(ByVal str As Int32) As String
Return "Hello, World! str=" & str
End Function
<html>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script type="text/JavaScript">
<!--
$.ajax({
type: "POST",
data: "&str=1",
dataType: "xml",
url: "<HTTP path and filename>.asmx/HelloWorld",
timeout: 15000,
cache:false,
success: function (result) {
alert(result);
},
error: function() {
alert("bad");
}
});
//-->
</script>
</body>
</html>
It shows:
[object XMLDocument]