I\'ve tried many things and there\'s no way, always appears this error I tried to use only one option to see if passed, changed the call of jquery, but not.
I looked
I suspect you're getting text/html encoding in response to your request so I believe the issue is:
dataType : 'json',
try changing it to
dataType : 'html',
From http://api.jquery.com/jQuery.get/:
dataType Type: String The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
The error SyntaxError: Unexpected token <
likely means the API endpoint didn't return JSON in its document body, such as due to a 404.
In this case, it expects to find a {
(start of JSON); instead it finds a <
(start of a heading element).
Successful response:
<html>
<head></head>
<body>
{"foo": "bar", "baz": "qux"}
</body>
</html>
Not-found response:
<html>
<head></head>
<body>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
</body>
</html>
Try visiting the data endpoint's URL in your browser to see what's returned.
make sure you are not including the jquery code between the
< script > < /script >
If so remove that and code will work fine, It worked in my case.
I suspect one of your scripts includes a source map URL. (Minified jQuery contains a reference to a source map, for example.)
When you open the Chrome developer tools, Chrome will try to fetch the source map from the URL to aid debugging. However, the source map does not actually exist on your server, but you are instead sent a regular 404 page containing HTML.
You have unnecessary ;
(semicolons):
Example here:
}else{
$('#resposta').addClass('warning-box').html('É necessário no mínimo duas opções');
};
The trailing ;
after }
is incorrect.
Another example here:
}else{
$('#resposta').addClass('warning-box').html('Coloque a pergunta da enquete');
};
Just gonna throw this in here since I encountered the same error but for VERY different reasons.
I'm serving via node/express/jade and had ported an old jade file over. One of the lines was to not bork when Typekit failed:
script(type='text/javascript')
try{Typekit.load();}catch(e){}
It seemed innocuous enough, but I finally realized that for jade script blocks where you're adding content you need a .
:
script(type='text/javascript').
try{Typekit.load();}catch(e){}
Simple, but tricky.