Can't load Javascript library: ERR_NAME_NOT_RESOLVED - javascript

I have an Apache web server where I must display some graphs and I must be able to do it offline. I have a couple of js libraries I must use in order to render the graphs and when I load my index.php page, it gives me GET http:d3.js/ net::ERR_NAME_NOT_RESOLVED, but the file is in the right folder and I've copied and pasted the code in index.php in a test file and when I open it, it works just fine.
The html for the graphs is being generated using the MPLD3 function of fig_to_html, this function generates an html string, that I append to my index.php, the path to the js libraries is also specified in that function:
mpld3.fig_to_html(fig, mpld3_url='file:///home/pi/webpage/mpld3.js, d3_url='file:///home/pi/webpage/d3.js')

Does not seem a valid file url:
http:d3.js/
Try "d3.js" or "/[path-on-site]/d3.js".

Related

JavaScript path doesn't load on Live Server extension (VS Code)

HTML and CSS files are working perfectly on my live server. But every time I lead to a .js script it will not be shown on my live server. If I try to load the .js file directly through the URL it shows "Cannot GET /line.js". I already tried out everything I've found on the internet but it's still not working. Here are the points I checked/did:
Installed Code Runner
Installed Node.js = node.js system path done
Settings = Live Server Config = specified browser
"liveServer.settings.CustomBrowser": "chrome" on JSON settings
.js file is in a separate folder and accessed via <script src="line.js"></script> on index.html
Chrome is set as default browser on my system
Thanks for your inputs.
If the js file is in a separate folder, you need to provide the exact route to the folder in the script tag, since in the current form it is trying to find the js file in the root directory. The script tag should look like this:
<script src="FOLDER_NAME/line.js"></script>
It's possible that your javascript file is being loaded before the HTML page is rendered. You can try adding "defer" to your script tag like this:
<script src="demo_defer.js" defer></script>

Display image on Html page

I'm trying to display a static image located in the same folder as my Html file but it seems I can't get the right path for it to display correctly. The application I'm developing is an atlassian plugin that also includes a java backend to get Data from the Database and I'm displaying it on the frontend using HTML and javascript, the whole application runs on a webserver as a Plugin. Both the image and the Html file are located in here: D:\clone4\project\src\main\resources\templates\scheduleraction
The URL path for the web application is:
https://staging.com/jira/secure/SchedulerAction!default.jspa
I tried many ways and this is the last one :
<img src="/SchedulerAction!default.jspa/piechart.jpg" alt="pie-chart">
I need to add the correct path in the "src" so the client can retrieve the image from my Files on the webserver. I would love any hint or help!
you should use exact path like ./Image.png. And avoid using Images out of the static HTML file located directory
Try to use a service to upload that image and use the provided url.
Such as https://imgur.com/. After upload it, use into the src the correct url with the filetype extension.

Cannot read a static file with d3.js in a Django template <script> tag

I'm using d3.js v3 for creating a Directed Graph in my Django template.
When I try to get data from a csv file as below,
d3.csv("file_name.csv", function(error, links) {
...
});
and use links, I get an error stating
TypeError: links is undefined
Also in the command prompt I can see an error that file_name.csv could not be found. I'm suspecting it is looking for the file in some other location rather than in the template's directory itself. But I've tried putting the file in static folder as well and have had no luck.
Note: However, if I open the html template directly in a browser and have file_name.csv in the same directory, everything works fine and I can see the graph being created.

scripts_for_layout generates a different hash on each page load

i have a site in cakephp version 1.2.1.8004, on the admin side scripts_for_layout is used to generate the css and js hash.
Every time on page load it generates a different hash.css file and hash.js file to call the css and js file, so it cannot call the correct css and js file which is present.
i checked on other site where the same hash is generated everytime.
This was due to incorrect permissions given to css and js folders. since it could not access the folders it would try to create a new file with new hash everytime.

PHP code-igniter

I'm having troubles calling my external js files from my views php pages. The js files are saved in the "resources" folder in the root folder i.e "root/resources/scripts/myfile.js" just like the "root/application" and the "root/system" folder.
so in one of my php files in the views folder i am using this code:
<script type="text/javascript"
src="<?php echo base_url();?>resources/scripts/welcome.js">
and this php file is located in "root/application/views/welcome.php"
and still my page cannot link with the java script so i am stuck big time.
regards
k..
Try this:
<script src="<?= base_url('resources/scripts/myfile.js')?>"></script>
Looking at your question and the comments below your question, it seems you are using "resource" in one example and "resources" in another example.
Once fixed, view the source of the page (I use FireFox, as it makes the links clickable), search for "welcome.js". Once found, click on the link for that file. If you see javascript, it means the file is found, alternatively you will see a 404 error.
First of all check if the resource folder is available,
The java script file is available and the file naming is in the same small or capital case, and server has public permission of the file and folder.
by the way your code has missing end tag
</script>

Categories