Hiya, quick question, why do many of the examples I have seen of Ajax enabled WCF Services wrap the javascript in CData tags? Am I missing something? I am using WCF Services and have successfully got it working without wrapping the scripts in the CData
tag...
A CDATA section is required if you are using XHTML in order for it to validate, as XHTML will parse the JavaScript code as parsed character data as opposed to character data by default (for example <, >, &). This is not an issue with scripts that are stored
in external source files, but for any inline JavaScript in XHTML you will want to use a CDATA section.
Mark DotNet ...
Participant
847 Points
190 Posts
Why does every WCF Example wrap the javascript in CData tags?
Oct 28, 2011 09:40 AM|LINK
Hiya, quick question, why do many of the examples I have seen of Ajax enabled WCF Services wrap the javascript in CData tags? Am I missing something? I am using WCF Services and have successfully got it working without wrapping the scripts in the CData tag...
ta
Anton Palyok
Contributor
2526 Points
404 Posts
Re: Why does every WCF Example wrap the javascript in CData tags?
Oct 28, 2011 10:55 AM|LINK
A CDATA section is required if you are using XHTML in order for it to validate, as XHTML will parse the JavaScript code as parsed character data as opposed to character data by default (for example <, >, &). This is not an issue with scripts that are stored in external source files, but for any inline JavaScript in XHTML you will want to use a CDATA section.
Refer to this articles:
http://www.w3schools.com/xml/xml_cdata.asp
http://javascript.about.com/library/blxhtml.htm
XIII
All-Star
182684 Points
23455 Posts
ASPInsiders
Moderator
MVP
Re: Why does every WCF Example wrap the javascript in CData tags?
Oct 28, 2011 12:47 PM|LINK
Hi,
take a look at this article: http://javascript.about.com/library/blxhtml.htm
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
matyvegan
Participant
849 Points
261 Posts
Re: Why does every WCF Example wrap the javascript in CData tags?
Oct 28, 2011 01:38 PM|LINK
is to prevent the javascript code broke the xml
Thanks!