From the course: JavaScript: Ajax and Fetch

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Test an XHR request

Test an XHR request - JavaScript Tutorial

From the course: JavaScript: Ajax and Fetch

Start my 1-month free trial

Test an XHR request

- You can test AJAX code in a browser just like you would any other front-end code. However, it's generally best not to simply open your HTML file in a browser and see what happens. This is because by default a browser opens a local file using the file protocol which browsers treat differently then pages open using HTTP requests including everything you open from the web. Fortunately, it's easy to run a simple HTTP server on your development computer, which lets you more closely match the way your AJAX code will work after you deploy it. In addition, some API's require requests to be linked to a specific URL. So, using a HTTP server is a must in a situation like that. I'm using Visual Studio Code editor with a Live server extension. This extension takes care of all the configuration for me. Similar extensions are available for Sublime Text and for Atom. So, whatever environment you're using, I recommend installing and using an extension like this. For Live Server, I need to start by…

Contents