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 - JavaScript Tutorial
From the course: JavaScript: Ajax and Fetch
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
What is Ajax?2m 23s
-
(Locked)
Understand asynchronous program flow2m 53s
-
(Locked)
Get an API key6m 42s
-
(Locked)
Research and create an Ajax request URL3m 50s
-
(Locked)
Create an XHR request5m 13s
-
(Locked)
Test an XHR request5m 51s
-
(Locked)
Handle XHR success and failure5m 38s
-
(Locked)
Challenge: Build an XHR request56s
-
(Locked)
Solution: Build an XHR request5m 3s
-
-
-
-
-
-