Syntax Error: "Unexpected token <" in Web Console - javascript

Why am I getting this error in the web console? It just says "line 1, col 1" with that error. When I click the link, I'm brought to the source of my homepage, and it's telling me it didn't expect the < in the doctype!
(For SEO: opening angle bracket, less than sign)

TL;DR
check bad path to file.js

In my case, I was using a javascript library and loading a theme file as part of the configuration. I misspelled the path to the file, which is what caused all of this. Why didn't it give me a better error message? Because I have my website set up to redirect all 404s to the homepage. So it tried to interpret my homepage HTML as the js theme file.
If you get a strange error like this, there's a good chance that you just made a typo.
If you redirect 404s to the homepage, it would probably be a good idea to disable it during development.

I don't know if this could help anyone as this is an old post.
If you are using any Text Editor like Sub Lime there is great chance that use selected the tag from intellisense and the opening tag "<" that you first typed is still there.Check if you could find any.In this case review your DOCTYPE tag in the beginning of HTML

Related

I couldn't find my .js file on firebug

Firebug made me crazy. I want to debug my javascript codes but I couldn't find my js file.
It show the error why is line of my search .js file but when I search I couldn't find.
I search PersonManagement.js on firebug
But when I search on script section on I couldn't find, I need to review via debug this file, I mean I need to find PersonManagement.js via firebug.
Could you help me?
If there is a syntax error within a JavaScript source, the source is not listed within the Script panel, though the syntax error is logged to the Console panel (assumed you have the option Show JavaScript Errors enabled).
This is also briefly explained within the Firebug FAQ and the Script panel description.
In your case you got the syntax error 'missing name after . operator'. Just remove the . between $ and ( and your problem should be solved.

Bug in Visual Studio 2015 package.appxmanifest for ms-appx-web in start page?

I'm creating a Javascript Windows 10 Universal app. It complained about using javascript inline with html-- due to having script tags inside my .html file.
"CSP14312: Resource violated directive 'script-src ms-appx: 'unsafe-eval'' in Host Defined Policy: inline script. Resource will be blocked."
So I did some research online and it turned out that I could avoid this error by doing two things:
Open package.appxmanifest:
add to start page:
StartPage="ms-appx-web:///index.html"
Add to package.appxmanifest:
<uap:ApplicationContentUriRules>
<uap:Rule Match="ms-appx-web:///" Type="include" WindowsRuntimeAccess="allowForWebOnly" /> </uap:ApplicationContentUriRules>
(You read this right: we need 3 slashes... ///)
Now this works great and my program is running now without the errors. But I noticed that if I change the start page via the GUI then it can't save it because it complains it's an illegal uri. So the only way I could do this was right-click the package.appxmanifest and choose "view code" and then do it through code. (Actually #2 above can only be done through code).
Maybe someone can clue me in, did I do something wrong? Here's a screenshot doing this through the GUI:
I saw a similar bug has been filed - when use the same uri format in manifest's Content URIs setting, same issue occurs. It's because the there is a rule checks whether the uri has a host. If the uri's host is null or empty, the uri validation fails.
Seems VS team is considering removing this rule, so I think it will be fixed in future release but I cannot say which update will have the fix.

jquery conflict with my website

I layout'd a page and on my server which is it hostgator works extremely fine, using the jQuery mobile components:
http://brunolustro.com/roger/teste/cadastro.html
But my friend who is programming the page wanted me to insert the newest CDNs from either jQuery and jQuery Mobile:
And this is what the page looks like when I insert those codes:
http://brunolustro.com/roger/test/cadastro.html
Do you know how to fix this?
Regards,
Bruno
When working with JavaScript or jQuery on your website - if something isn't working as you intend - the first thing you should do is check the browser console to see if anything is being logged there.
To check the browser console:
Hit F12 on your keyboard. When the developer tools open, choose the console tab, its placed in the toolbar at the top of the new window.
In the console you will see a few errors in red with error codes (404). A 404 means the requested file wasn't found.
This tells us that your reference to jQuery isn't correct. This could be because the file path you've written isn't correct, or that you haven't deployed those files correctly to your site.
Check your file paths you've referenced and make sure the file is on your server. Once both are correct - the errors should go away.
Here's a link to view more about developer tools: https://developer.chrome.com/devtools#console
Check following files in your "test/js" and "teste/js" folders, because i've got 404 not found error:
jquery-2.0.3.min.js
modernizr-2.6.2.min.js
jquery.mobile-1.4.5.min.map

Javascript error/WebResource not found on a page with RequiredFieldValidators

A friend on mine is having an issue on one of his webforms, he referrs that everytime he loads one page containing RequiredFieldValidators the page throws the following Javascript/WebResource error:
Mesagge: Syntax error
Líne: 3
Character: 1
Code: 0
URI: http://localhost/miproyecto/WebResource.axd?CCL=ynu3FmO0gS8j
I thought that the issue could be related to a forms authentication problem so He allowed the resource to be a permitted file like this:
http://connect.microsoft.com/VisualStudio/feedback/details/105101/forms-authentication-using-login-control
However the problem persists
I wonder if there is a way to get rid of the issue.
Regards,
CR
Edit:Forgot to mention that when he comments the RequiredFieldValidators on the page, the error is gone. But the idea is to keep them.
He had a .js file linked to the page and this was causing the error. Once it was commented the page worked.
Thanks!

Debugging an error message in Firebug

I get this error message in Firebug:
Permission denied for <http://googleads.g.doubleclick.net> to call method Location.toString
It comes from this page:
http://www.comehike.com/outdoors/trees/add_spotted_trees.php?hike_id=108
The login credentials for this page are:
test#comehike.com | password
When I look at it in Firebug, using the Console --> Errors view, I see that error first, followed by a number of other errors, but I can't really double-click on the errors to see what line they are coming from, and the line isn't written there as far as I can see. There are some line references on the page, but they lead to pretty random spots.
Any ideas how to debug such a thing? I am new to JS and FireBug.
Thanks,
Alex
The Location.toString error is usually due to some ad-serving javascript code, trying to get a text version of the current page's location. Firefox denies access to this information to 3rd party scripts by default, since 3rd party scripts should have no business knowing exactly what page you're on.
Basically it's an attempt by ad networks to work around some clients not sending referers, by trying to grab the location data directly.
In firebug under the "bug" icon (upper left when open) you'll see a pause button (in the console tab). This will cause the page to stop loading and jump to the exact error in the script.
However, when I visited the page I do not see any errors.
body' onLoad is:
initializeTreeHike( , );
You don't need to use comma if you wish to pass no parameters to the function.
When I follow the provided link in Firefox 4.0 with Firebug 1.7, I don't receive the error you encountered. What I do receive however is the following:
Syntax error: initializeTreeHike( , );
It appears this is coming from line 326 in add_spotted_trees.php in the following line:
<body onload="initializeTreeHike( , );"
Perhaps you meant to pass in empty strings as parameters?

Categories

Resources