Including .js but failed to load resource - javascript

I'm writing a html file that includes several .js libraries from open sources Projects for example:
<script src=“js/three.min.js"></script>
But it says:
Failed to load resource: the server responded with a status of 404 (Not Found).
When I clicked on it, it says The requested URL /blabla/js/three.min.js was not found on this server. The .js files are in the folder called js which is stored in the same place as the html file. I've already gone through tons of Google search but couldn't find a way to solve it. Maybe it's a dumb question as I'm new to JavaScript. Can anybody kindly inform me what is the problem?
Many thanks in advance!

Can I see your code? In meantime, you can have reference from below
<script type="text/javascript" src="http://www.your_external_domain/blabla/js/three.min.js"></script>

Is the file local or online ?
If online try to call http://www.your_external_domain/blabla/js/three.min.js with your browser.
If you can receive the file with your browser, your html should be although able to do it.
If not, maybe you cannot receive this file from your school server.

Everyone is answering saying he has to add type="text/javascript" as well.. but this isn't necessary anymore. If script tags do not contain the type property, it's Javascript automatically.
I read you're on your school server, so that might be it.. (the directory might require to read your username and password).
Try uploading the file somewhere (maybe here: http://yourjavascript.com/) and referring it that way.

Try <script type="text/javascript" src="/js/three.min.js"></script> (added a / in front of js).

Related

JavaScript Library not working on server but it's working on local server

I'm working on Laravel project and I'm using :
cookieinfo.min.js
I'm facing a problem that the Cookies message is displayed on the local server but not working the online server
<script id="cookieinfo" src="/assets/frontend/js/cookieinfo.min.js"></script>
and I'm getting that message in the console
GET https://example.com/assets/frontend/js/cookieinfo.min.js net::ERR_ABORTED 404
but all the other scripts are working fine on the live server
can anyone give me any advice or a fix to that bug
Use Proper Url
{{url('/assets/frontend/js/cookieinfo.min.js')}}
When cut .htaccess and index.php files must give public folder as path.
Try with this
<script id="cookieinfo" src="{{URL::asset('public/js/cookieinfo.min.js')}}"></script>
OR
<script id="cookieinfo" src="{{URL::asset('frontend/js/cookieinfo.min.js')}}"></script>
UPDATE :
Blade allows you to push to named stacks which can be rendered somewhere else in another view or layout. This can be particularly useful for specifying any JavaScript libraries required by your child views
#push('scripts')
<script src="/assets/frontend/js/cookieinfo.min.js"></script>
#endpush
See more https://laravel.com/docs/master/blade#stacks

Why can't I get my script tag src's to work?

I have been coding up a localhost, and I made the localhost by using of course a JavaScript file to do so, and I then made it reference an HTML file. However, I noticed that when I am using localhost to serve up the HTML file I get this error:
"GET http://localhost:3333/filetesting.js"
The filetesting.js is that js file, there are also other things I'm referencing too, like websites. I'm referencing it by using script tag src.
I looked at the network on developer tools of it and it says it's a 404 error not found. I'm trying to figure out how to reference my script tag src's without having localhost:3333 go before it.
When I run the HTML file without using the localhost, it works just fine when it comes to the script tag src's. If you do not entirely understand what I'm asking for, just ask.
Assuming that your script will always reside in the root level of your website, you can simply target it with the root-relative prefix /:
<script src="/filetesting.js"></script>
This will load your script from the root, regardless of the site the file is hosted on. For example, on http://localhost:3333/ it will load the file from http://localhost:3333/filetesting.js, and from http://localhost:3333/folder/, it will attempt to load the file from the same location.
If you move your files over to a proper website, it will still work the same way: www.example.com will look for the file at www.example.com/filetesting.js, and www.example.com/folder/ will look for the same file at www.example.com/filetesting.js.
Hope this helps! :)

Error performing Cross-Origin reading of a csv file using JSONP

Background:
I have a html and javascript program with which I want to use to get data from an excel file (file is located on my computer, in the same folder as my code and file type is csv although ideally I'd rather read xlsm if possible however I suspect csv is easier). I then want to be able to use this data to do a bunch of things. Ideally I want to be able run this in an iframe within a google earth (the desktop application) bubble however getting it running in any one browser would be okay. So far I have been trialing it in Chrome, IE, and an iframe in Google Earth but I've run into problems.
So apparently even though these files are on my computer in the same folder as my html and javascript this is considered a cross domain request. I am unable to change the server in any way and I have heavy restrictions on what I can download to such an extent that you can just assume that downloading something is not a solution. Doing some research I came across JSONP so I have been trying to use this method to get the data. However I'm running into issues trying to get it working and I'm not sure why.
Code:
This is the relevant code in my html file:
<script type="text/javascript" src="file:\\\O:\user name\folder name\filename.csv?callback=mycallback"></script>
Error:
This is the error I get in Chrome:
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///O:/user%20name/folder%20name/filename.csv?callback=mycallback
I am not sure why the file is not being found. Any suggestions? I was wondering if the spaces in the foldernames are causing the issue? I hope this is not the case as I am unable to change the "user name" folder name to not have a space :-/. Thanks for any help.

JavaScript = "js"? Is this valid?

I inherited a website, I'm trying to serve its content over https, but when I do so I get an error that this "content" is being delivered insecurely. The certificate and all that good stuff is set up correctly.
<script type="text/javascript" src="https://domain.com/?dynamic=js"></script>
This doesn't seem to actually reference a file. I've googled but can't find anything to lead me in the right direction. Can anyone provide some insight, or better yet explain why this leads to the security problem?
Yes, it is valid so long as https://domain.com/?dynamic=js generates a javascript file. See this page for more info on dynamic files:
http://www.dynamicdrive.com/forums/showthread.php?21617-Dynamic-external-js-scripts-and-css-stylesheets-with-PHP
If you are running under secure connection (https) then all the resources in your domain have to be also serving via https - like images etc...
check to see if some image is using http: and not https
There's no problem with the script-tag. You don't actually need a .js-extension for it to be valid, as long as it returns JavaScript the browser will be happy.
Also, this line has nothing to do with the HTTPS-error you're getting. You should make sure that ALL the content linked on that page is delivered through HTTPS
Make sure ALL of the assets on the page are served up with relative paths. Images. css. scripts, etc.. Then they will load no matter if you are on https or not.
Relative = "/images/test.jpg" instead of "http://test.com/images/test.jpg"
Also can do Protocol relative url : "//test.com/images/test.jpg" (Thanks to commenter)

how to get full path from fileupload using Javascript

I need to know how to get full path from fileupload using javascript,
I tried using the following coding but of no use
<input type="file" id="picField" onchange="preview(this)">
<script type="text/javascript">
function preview(test){
var source=test.value;
alert(source);
}
</script>
but in the alert message, i am getting only
Filename.extension
I am not getting full path, but it is showing full path in File Upload box please help how to solve this problem
Thanks
This is a browser security restriction, in modern browsers you cannot get the full client file-system path of the selected file, nor set a path programmatically...
Maybe for security reason, javascript doesn't allow this to happen. And if you come to think of it, Server side pages cannot access your local files. Not that I have a solution for your question.
Actually, there is some kind of solution.
Albeit, it will help only if you can run Electron desktop app on local machine: https://stackoverflow.com/a/59990858/9390914

Categories