From the course: Building a Website with Node.js and Express.js
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Updating the page from REST
From the course: Building a Website with Node.js and Express.js
Updating the page from REST
- We just added the feedback.js client-side JavaScript to the page. And now let's look into this script to understand what it's doing, basically. So I'm going to static, js, ENTER, open feedback.js. And you see those dollar signs here, they are related to jQuery, it's more or less a shortcut, provided by jQuery and (unintelligible) just complains because it doesn't know them. What I want to show you is this function that does this XHR request. It starts in line 55. So it attaches and this is what jQuery basically does. It attaches to CSS classes, or IDs. And there it attaches to the feedback form and it attaches there to the Submit event. So when someone hits Submit, we first, in line 57, prevent the default. This means the form won't be sent then by a regular means. And then we initiate the post request. So in line 61, you see that we are posting to feedback/API. So that's the endpoint we created before. And starting…