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

JavaScript

How can i get this to work using my own source code editor (VS code)?

i copied the folders over to my local and tried running through VS code and am getting the following error:

Failed to load: <path to the file>:Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

2 Answers

Your question is not attached to any specific lecture so I can't really tell what code it is you are trying to run, but based on the error message I assume it involves making AJAX requests or something along those lines. When you request a resource using AJAX it has to be hosted on a server. Browsers generally do not allow you to load them directly from a local file, which I'm assuming is what you are currently doing.

That does not mean you can't test this code locally though, you just need to install a dev server on your machine. I don't use VS Code much myself, but I see that there is a VS Code extension called Live Server that should work well for you.

It is pretty simple to use (just install it and then follow the step by step guide on the page I linked to) and it claims to have CORS enabled by default, which is usefull when you are testing out AJAX calls.

for some reason i am unable to link to the session in the main question . The session is the Ajax basics -->Processing-json-data

https://teamtreehouse.com/library/processing-json-data

That worked!

Thanks!!!