Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Forked from jquerygeek/validator
Created October 16, 2012 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xjamundx/3902535 to your computer and use it in GitHub Desktop.
Save xjamundx/3902535 to your computer and use it in GitHub Desktop.
validator.nu client-side
// easy way to get current pages HTML
$.get('#', function(html) {
// emulate form post
var formData = new FormData();
formData.append('out', 'json');
formData.append('content', html);
// make ajax call
$.ajax({
url: "http://html5.validator.nu/",
data: formData,
dataType: "json",
type: "POST",
processData: false,
contentType: false,
success: function(data) {
console.log(data.messages); // data.messages is an array
},
error: function() {
console.warn(arguments);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment