I have a json data on localhost. I want to add it to pie chart. My html page is ready but I have an error about jquery. When I open the html page console says me, "js/jquery.js" file not found. My file is here i controlled it
jquery.js
And this errorError: "Failed to load resource: net::ERR_FILE_NOT_FOUND"
How can i do against that problem? Thank you
you must specific location folder JS
example: (in folder : www/your_app/js/)
to test bugs? click right in your browser and view source, and click again your js/jquery.js, if not found? you was wrong link into folder JS
It sounds to me like you have either an error in the path to the file or the file does not exist.
Try the opening the link to your jquery file in your browser to see if it is there. If it is there, make sure the link to the file does not have any spelling mistakes and that you are not missing any directories
You don't need type="text/javascript" anymore in HTML5, concerning your file, it does not exist or the path is wrong so verify this by entering the source address in your browser to check that or simply copy and paste the relative path to be certain it is alright.
Related
I'm trying to make a chat application using socket.io and Node.JS. In my html file called index.html, I am trying to use a script tag to point to a script file called bundle.js that contains a browserified set of variables and functions.
The problem is, despite referencing the proper path in my src attribute, the tag seems to include a bundle.js within my localhost:3000.
Oddly enough, when viewing this bundle.js with developer tools, the content seems to be identical to that of my index.html file. This creates a syntax error as the JavaScript file contains html syntax from my html file. Any ideas why this might be?
<script src="bundle.js" type="text/javascript"></script>
This is how the script tag appears in my html file.
This is a link to a screenshot of my developer tools (New here so not enough rep to post the actual pic)
As we can see bundle.js is open in developer tools is Html code, not js that's why error is shown in first line, or there is something wrong in webpack configuration.
In the network tab of the developers tools, my external javascript file is being read as a json file instead even though it is saved as javascript. I am not sure how to go about fixing this.
EDIT:
Don't have enough rep to post images here, but the link to the left shows that my file is saved as a javascript but the file type says json.
EDIT #2:
function hello(){
alert("Hello, World");
}
just trying to use that lil bit of code to try to get the file itself to work.
EDIT #3:
So i changed the src path as mentioned by user onetwo12 said but the file is still getting a 404 error.
Alright, thanks for your guy's help but after looking where the css files were at, it looks like the scripts and anything else I make will be called from the static directory first and then into whatever I call in the src. So i moved the js directory from outside static directory into the static directory and got things working.
I'm completely new to JavaScript and D3.js. I have done some work in recent days, like making appropriate json object for the graph, and wanted to know how to get this example running in particular. Any direction to appropriate links would be great, though I would prefer to get an answer in the form of any missing tags or any details I need to take care of.
Note: I have to run it locally, not on server-client model.
Update: I have done it a lot of times what Bill answered, it didn't work. So I tried again and I opened the console in browser to check for any errors. Got this:
Failed to load resource: file://d3js.org/d3.v3.min.js
net::ERR_FILE_NOT_FOUND
index.html:23 Uncaught ReferenceError: d3 is not defined
The point is that you cannot access files on your computer from javascript using file:// (think that people could access all your file...).
So you have to use <script src="address/d3.js"></script> here, address correspond to the address of your server (http://domain.com or http://localhost) or the relative path.
For example, you can download d3.js next to your html file (same folder) and just type <script src="d3.js"></script>
Hope this helps
You can do the following:
Go to https://gist.github.com/mbostock/4062045
Click on the Raw button next to index.html
Copy everything and paste it into a file on your computer called index.html
Go back and click on the Raw button next to the .json file
Copy everything and paste it into a file on your computer called miserables.json (make sure this file is in the same folder as index.html)
Double click on index.html, it should open in your browser
When copying and pasting the following code for a Twitter button into a text file:
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
I get a javascript error saying 'failed to load resource file://platform.twitter.com/widgets.js'
What could be causing this? Thought I should be able to just copy and paste the code from Twitter.
You're trying to load a protocol-less URL in a local file. Twitter is serving its script via //platform.twitter.com/widgets.js, which translates to the file: protocol locally. That's the best practice for serving content (it will not generate those annoying mixed content warnings in IE), but just plain won't work in local files.
Try updating that line of the script to https://platform.twitter.com/widgets.js. That should help you test locally; once you're done testing, flip it back to the protocol-less structure.
Are you sure you've entered the code correctly?
Try using a direct link target for your button like this:
just change the URL to wherever you want to point it, and the username to whatever username you use.
This code is the code from the site:
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
Should the src be "https://......" rather than just "//....." ?
New to ASP and probably never named a Javascript file ".inc" :-)
But that seems to be the norm where I'm currently working.
I observed that right on the first page I started getting these javascript errors
Message: 'globalVariableXXX' is undefined
I found that the javascript file wasn't getting called at all.
Just changed the name to ".js" and it worked !!
The ASP file includes the JavaScript file like this :
<SCRIPT LANGUAGE="Javascript" SRC="include/MenuCode.inc"></SCRIPT>
But there are 100's of these ".inc" files and 100's of references to them, hence don't want to go with this solution.
I'd rather understand it..
Any idea why it would've worked in the first place and why it isn't now ?
I'm sure I'm missing something pretty basic in ASP..
Another point : This application is installed on another server and it works just fine there when I hit it. I'm trying to install it on this new box.
Where I made the change for it to work:
In IIS, Right click on the name of the machine and the Mime Types are right over there. Checked the old server and it had the settings for ".inc", copied them and it started working :) Thanks all.
Maybe someone changed the webserver to prevent it serving .inc files ?
In the management console (inetmgr) right click the website and choose Properties. Go to "home directory" tab and click Configuration.
You will probably see the .inc extension there (in the mapping tab) meaning those files are parsed by the ASP engine.
Remove the item from the mappings table, apply and you should be able to parse those files as raw data.
The proper way to use a script tag for javascript is with the type attribute, such as
<script type="text/javascript" src="include/MenuCode.inc"></script>
see: http://www.w3schools.com/tags/tag_script.asp
language isn't even listed as a supported attribute by the standard..
Edit: The reason .js worked and .inc didn't is .js is in the mime type definitions of the server as a JAVASCRIPT mime type by default. If not using an extension configured as text/javascript by default, you have to tell the browser what to treat the file as somehow. This is why the text attribute of script is a required attribute as per html 4.01.