1

While validating this snipit:

<script type="text/javascript" charset="utf-8">
    /* <![CDATA[ */             
    jQuery.post('http://domain.com/dev/wp-admin/admin-ajax.php', {action: 'wpp_update', token: '2e85204387', id: 214});
    /* ]]> */

</script>

I am getting the validation error: "Element script is missing required attribute src."

The page has an HTML5 doctype and is encoded as utf-8.

2 Answers 2

3

http://www.w3schools.com/TAGS/att_script_charset.asp

The charset attribute specifies the character encoding used in an external script file (referred to by the src attribute).

In other words, you shouldn't be using the charset attribute here, since you're not using an external script file. If you remove it, it'll validate.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm in agreement on this one. Dump the charset attribute on your script tag and set the META tag for the content type and or (and you'll have to pardon my ignorance on HTML5) use an XML decl <?xml version="1.0" encoding="UTF-8"?> and save the file with that encoding.
0

Try moving the charset out of the 'script' tag and into a 'meta' tag. Charset is no longer supported as part of script in HTML5. Also note 'type' is no longer required.

Also you can remove the /* <![CDATA[ * / open and close.

See this link for a good example of handling character encoding. See this link for info on what attributes are supported in HTML5.

2 Comments

Type is no longer required on a script block in HTML5? That's ... interesting.
In the context of this question, no, it is not. In HTML5 it defaults to "text/javascript".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.