Reputation: 351
I used AJAX to get a Json object from a web method. Most elements can be decoded well, except the "Content" element.
The following is the Json Object.
{"d":"\u003cNewDataSet\u003e\r\n
\u003cId\u003e13410\u003c/Id\u003e\r\n
\u003cContextId\u003ee055817c-9233-12d1-a559-ff03465875af\u003c/ContextId\u003e\r\n
\u003cTimestamp\u003e2014-09-19T21:40:02.97-07:00\u003c/Timestamp\u003e\r\n
**\u003cContent\u003e\u0026lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\u0026gt;\u0026lt;SOAP-ENV:Header\u0026gt;\u0026lt;/SOAP-ENV:Envelope\u0026gt;\u003c/Content\u003e\r\n**
\u003c/NewDataSet\u003e"}
When I use $().html(Id)
or $().html(ContextId)
or $().html(Timestamp)
, it shows correct data content in the web page; however, using $().html(Content)
is showing nothing....
If I just use alert(Content)
function of jquery, it can show the correct format like
< SOAP=ENV:Envelop xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelop/......>......< /SOAP-ENV:Envelope >
I can't figure out why only "Content" element didn't act correctly like other elements...
Upvotes: 0
Views: 322
Reputation: 14549
Try $().text(Content)
as this will HTML escape your content. Otherwise your content
that contains tags will be interpeted as tags which are unknow to the browser and ignored.
Upvotes: 1
Reputation: 10743
You're trying to create a soap envelope as html so it won't work; that's not valid html. You can see it in an alert because you're asking for text. This would be valid Javascript:
var strSoapEnv = Content;
Upvotes: 0