Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Shira Lotan](https://secure.gravatar.com/avatar/e65b32aedc704323182e2b5870cc6f6d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Shira Lotan
3,040 PointsUse Ajax on local file
I have a file named homepage.js which contain an Ajax request and append info to the page. I have a main.js file and here I want to create an Ajax request to the homepage.js. Is it possible? My local path (of homepage.js) starts with file:// and it looks like its not valid. Any solution for this? $( document ).ready(function() {
$.ajax({
url: 'file:///Users/shiralotan/Desktop/Project%20BTC/homepage.js',
success: function(resualt){
$("#coinsDiv").html(resualt)
}
})
})
1 Answer
![Brendan Whiting](https://uploads.teamtreehouse.com/production/profile-photos/2109002/micro_picture.jpg)
Brendan Whiting
Front End Web Development Techdegree Graduate 84,736 PointsCan you share the rest of the code for the project, either on GitHub or a Treehouse workspace snapshot? FYI, it's good practice to develop your website by serving up your with a local development server like http-server rather than viewing them in the file system (file://
).
What's the goal here? What is in homepage.js
that you want to fetch with an AJAX request? Could you just load the script for homepage.js
along with the other scripts at the beginning when the page loads?