JavaScript critical error - javascript

I am unable to include any javascript file in either the _Layout.cshtml or any other view. When I do so, I get the error "javascript critical error at line 3...". I'm using IE to browse. Errors are not shown in Chrome though. I am including the js file at the bottom of the view like this:
<script src="~/Content/bootstrap/js/bootstrap.min.js"></script>
The error is not specific to this file, any js file gives the error. I also tried sing the url.content, no luck. Thanks

To me it seems quite unrelated to ASP.NET since you are including a static JS file, so it's pure HTML.
I suppose in this case you should remove the tilda character ~ from file URL.

Related

"Failed to Load Resource Error" despite file being in directory

I'm programming a project using HTML and JavaScript. I access my js code with the following script tags:
<script src="js/monthChanger.js"></script>
However, when running my program in Edge & Google Chrame, I keep getting
this error.
Why is this happening? Looking at my file directories there doesn't seem to be anything wrong with the way I declared the function.
check out this article on absolute and relative paths
you probably want this:
<script src="./js/monthChanger.js"></script>
The ./ makes it relative to the current folder.
Alright, so it turns out my issue had nothing to do with HTML.
I didn't specify this in the OP, but I was also using a Django's framework in my project. I had mistakenly assumed that static fields such as css, js, and images would be called the same way they are called in normal html files. However, after reading django's documentation on managing static files, I realize that this is not the case. I follow django's instructions and was able to get my code working.

Inline javascript in flask jinja2 templates not showing up in firefox/chrome debugger

I'm taking over a flask project where the previous dev wrote quite a bit of their javascript/jquery in inline script tags in template files instead of separate js files in a static folder.
There's an issue with table cell highlight occuring after a long delay and I can't find the source in firefox/chrome debugger to step through the code. All the javascript I see is from the base template(can't see this either in chrome).
How do I view this injected template html and internal javascript in the debugger or is there another way to debug this without reworking the entire template and moving the javascript to another file?
I did not see in firefox debugger a javascript file that I placed in the static folder and referred from *.html file.After following this tutorial I saw that it is possible. I started commenting out parts from my application, hoping to find which part is causing this issue.In the end, I found out that my javascript file contained wrong syntax in one of the "if" conditions:
if foo() {
instead of
if (foo()) {

How to correctly include a javascript file into html

I am trying to run a script through HTML but I am having some problems. I searched online and found how to do so, however the issue is that even if I correctly type the path of the .js file, it seems to add some strange characters before it.
This is in index.html
<script type="text/javascript" src="fractalTest/fractalTest.js"></script>
I expected this to work but when I open index.html in google chrome and inspect then look under the elements tab, this "â©fractalTest/fractalTest.js" is replacing "fractalTest/fractalTest.js" in the path of the file. I believe this is whats causing the error but I do not know how to fix it!
...it seems to add some strange characters before it.
That usually means that the file is saved with a byte-order mark (BOM) of some kind, but isn't being sent with the correct charset for that byte-order mark.
Be sure that the server is configured to serve the files with a specific encoding (UTF-8 is a good choice), and that you save the files using that encoding (in your text editor, etc.). It's also usually best not to include a BOM on UTF-8 files (although it's valid, some tools don't handle it well).
Side note: No need for the type attribute. The default is JavaScript.

color picker plugin script import cause unexpected token

I'm trying to import color picker plugin (http://www.eyecon.ro/colorpicker/) into the backend of easyappointments.org, I follow the plugin documentation and the example page, but for a strange reason when I insert the script to the head of the backend page I get this error:
Uncaught SyntaxError: Unexpected token < jquery.js:1
this is my structure of import:
<script type="text/javascript" src="application/third_party/js/jquery.js"></script>
if you want see the complete code check this link.
The code is too long, sorry if I not pasted here.
How can I figure out what is causing this problem? I am a bit 'rusty with js and this problem is stopping me a little'
UPDATE jquery content:
http://pastebin.com/ee01ifzh
Edit:
After some detailed discussion of the problem, we found the correct solution:
the inclusion of the CSS and JavaScript files was wrong. All CSS and JS files need to be placed in a js folder in the project root, as the third_party folder is for php extensions only.
Inclusion order was also important. When including JavaScript, make sure to include the most basic scripts first. In this case, begin with JQuery, follow up with additional libraries like timepicker and include your own js last.

External javascript file not working

I have some javascript that's loading just perfectly at the bottom of my site. I wanted to externalize this aforementioned js, so I'm now linking to the code externally, but now the code breaks and is pointing to an error (not within the js file but the jquery file). What changes when the js is externalized? Are variables retrieved in the same way?
Thanks
You probably added the <script> tags in the wrong order.
you can probably use firebug and see whats happening there.
there is net panel which shows whethere that particular js is downloaded propery or not.
after that you can see the errors on the console window of firebug to find what exactly is the error.

Categories