Book Image

AJAX Next Level (Authentication, Servers, Modules, Projects, and More) [Video]

By : SkillZone .
Book Image

AJAX Next Level (Authentication, Servers, Modules, Projects, and More) [Video]

By: SkillZone .

Overview of this book

AJAX allows your users to add/delete/view/update content, post comments, submit reviews, submit forms, and a ton more, without getting a page refresh. This course will captivate you with real-life examples and catapult you to the next level and set you well on your way to achieving everything you want to with AJAX. This course introduces you to AJAX and lays the foundation. Later on, you will start digging into advanced concepts such as Basic Auth, CORS, and servers. In this course, you will learn how to send authentication information using the XHR object and the Fetch API. You will see how to take user inputs, convert them into JSON data, and send that data to a server. Understand how to retrieve XML, JSON, and text data from a server. Look at how to take data from the server and update the page dynamically using JavaScript. You will also learn how to write great code using modules, write middleware and define RESTful AJAX APIs, and more. Finally, you will build a fully functional site that performs basic CRUD operations and saves data to a server. This simple application will use the power of RESTful AJAX APIs to speak to a server and perform tasks like adding/deleting/updating and viewing data that is stored on your server. By the end of this course, you will be able to “speak” and “walk” AJAX by gaining an understanding of how you can use it in meaningful and practical ways. All the resource files are added to the GitHub repository at: https://github.com/PacktPublishing/AJAX-Next-Level-Authentication-Servers-Modules-Projects-and-More-
Table of Contents (11 chapters)
11
Conclusion
Chapter 7
Course Final Project – Task 2 – XMLHttpRequest (AJAX API)
Content Locked
Section 5
Fixing CORS by Writing a Custom Middleware Function
In the previous video, we wrote our AJAX GET request. But what happened when we clicked on the GET button? That's right, we are faced with a CORS error. This is because our front-end code is being run on port 5500 and it's sending a request to port 3000. There are a few ways we can fix this CORS issue. This video shows you the hard-slog approach, by writing our own custom middleware.