Javascript and jQuery not working in htdocs xampp folders

So, I created a site using HTML, CSS and Javascript and saved it to my desktop. Then I created a local server using xampp. I put this html file in the htdocs xampp folder. The file is called "foodlist.html". Whenever I try to open this tone in the webbrowser as localhost / foodlist.html, the jQuery and Javascript file contents are not displayed. Here is some of the code:

<link rel="stylesheet" href="main.css" />
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script id="javascript" src="file:///C|/Users/Akshat/Desktop/Project/JS-jQuery/addnremove.js"></script>

      

How can I get javascript and jquery code to work every time I open the file in the browser using / localhost?

+3


source to share


2 answers


file:///C|/Users/Akshat/Desktop/Project/JS-jQuery/addnremove.js

is not a valid address, this way of connecting even with the correct address will not work for security reasons ..

For this, for example, your XAMPP directory is "C: \ xampp", you can copy the "C: \ Users \ Akshat \ Desktop \ Project \ JS-jQuery" folder to the "C: \ xampp \ htdocs" folder and link yours " addnremove.js "file as follows:



<script id="javascript" src="http://127.0.0.1/JS-jQuery/addnremove.js"></script>

      

You can even change the address http://127.0.0.1/

with http://localhost/

.

+1


source


it looks like "file: /// C | /Users/Akshat/Desktop/Project/JS-jQuery/addnremove.js" is not a proper file link. try to put this file relative to your html as you did with main.css



+1


source







All Articles