[imps] using the validator.nu API
WebDevTutorials Support
support at webdevtutorials.net
Tue Dec 3 13:54:29 PST 2013
Hi,
I have been working on a website recently and would love to be able to use the validator.nu web service api. I have tried numerous other HTML validators, but none have good RESTful APIs.
To be more specific, my website has a code editor on it, and users can type code on it. When they click a check button, the following code is executed in jQuery/Javascript:
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
alert(xmlhttp.responseText);
document.getElementById("responseWindow").src = "data:text/html;charset=utf-8," + xmlhttp.responseText;
}
}
xmlhttp.open("POST", "http://validator.nu", true);
xmlhttp.setRequestHeader("Content-type", "multipart/form-data; boundary=doNotIncludeXadovAUvAvlBryUDSk5ZcdipW1fm8v79qYnXYmDG");
xmlhttp.send("laxtype=yes&parser=html5&content=" + editor.getValue());
The code opens an xmlhttprequest and sends a POST request to the API, as described in this documentation:
Validator.nu POST Body Input
To use Validator.nu as a Web service by POSTing an entity body, the client issues an HTTP request either to http://validator.nu/ or http://html5.validator.nu/ using the POST method. The document to check is included as the entity body of the request. The Content-Type request header must be used to communicate the MIME type of the entity body. Common parameters are encoded as query string parameters.
Only & is supported as a query parameter separator. ; is not supported.
Percent-encoded octets in the query string must decode to UTF-8.
Unfortunately, this isn’t working. The server sends a response, but it says:
Info: The Content-Type was application/octet-stream. Using the XML parser (not resolving external entities).
Fatal Error: Empty document, with no root element.
Have I used bad syntax? I must not be understanding the documentation correctly? Can anyone offer a suggestion?
Thanks,
Jackson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/implementors-whatwg.org/attachments/20131203/52931891/attachment-0001.htm>
More information about the Implementors
mailing list