![]() |
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
|
|
#1 (permalink) |
|
Member
Counter-Terrorist
Join Date: Nov 2006
Posts: 233
|
s the validator at fault?
I wrote a script that grabs quite a bit of data to pass as post data to a PHP script via ajax. When I tried to validate the page, I got all kinds of errors about ampersand entities. Obviously, replacing them with & will make the data request NOT work, so is this a fault with the validator (i.e. the document IS valid) or is there some other way I should be doing this? Here's a mini-example with GET: html4strict Code: 1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2. <html xmlns="http://www.w3.org/1999/xhtml"> 3. <head> 4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 5. <title>Validator Test</title> 6. <script type="text/javascript"> 7. 8. var exampleGetString; 9. exampleGetString = "?somedata=1"; 10. exampleGetString += "&failedvalidation=1"; 11. 12. </script> 13. </head> 14. 15. <body> 16. </body> 17. </html> |
|
|
|
|
|
#2 (permalink) |
|
Member
Hostage
Join Date: Nov 2006
Posts: 39
|
It's kinda your fault. As xhtml, you need to declare the script to be cdata.
Code: <script type="text/javascript"> //<![CDATA[ var exampleGetString; exampleGetString = "?somedata=1"; exampleGetString += "&failedvalidation=1"; //]]> </script> The browser doesn't care, because it's treating the doc as html, but the validator takes you at your word. Even if validating html, it's probably a good idea to enclose the script within comment tags. Not sure on the last, as I haven't written an html page in ages. cheers, |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|