Category: Ajax

Introducing Axios, a Popular, Promise-based HTTP Client

Axios is a popular, promise-based HTTP client that sports an easy-to-use API and can be used in both the browser and Node.js. Making HTTP requests to fetch or save data is one of the most common tasks a client-side JavaScript application will need to do. Third-party libraries — especially jQuery — have long been a ...

Introduction to the Fetch API

In this article, we’ll learn what the new Fetch API looks like, what problems it solves, and the most practical way to retrieve remote data inside your web page using the fetch() function. For years, XMLHttpRequest has been web developers’ trusted sidekick. Whether directly or under the hood, XMLHttpRequest has ena...

Using Fetch

Whenever we send or retrieve information with JavaScript, we initiate a thing known as an Ajax call. Ajax is a technique to send and retrieve information behind the scenes without needing to refresh the page. It allows browsers to send and retrieve information, then do things with what it gets back, like add or change ...

Fetching Data from a Third-Party API with Vue.js and Axios

More often than not, when building your JavaScript application, you would want to fetch data from a remote source or consume an API. I recently looked into some publicly available APIs and found that there is lots of cool stuff that can be done with data from these sources. With Vue.js, you can literally build an app a...

Animate in Ajax’d Content to its Natural Height

Let’s combine three things we just learned here on CSS-Tricks: One, transitioning to auto dimensions. Two, Ajaxing for stuff in a modern way. Three, waiting for images to be loaded to measure them. With all these three things in our toolbox, we can Ajax for some arbitrary content and insert it onto the page with...

Need to do Dependency-Free Ajax?

One of the big reasons to use jQuery, for a long time, was how easy it made Ajax. It has a super clean, flexible, and cross-browser compatible API for all the Ajax methods. jQuery is still mega popular, but it’s becoming more and more common to ditch it, especially as older browser share drops and new browsers ha...

Cache Fetched AJAX Requests Locally: Wrapping the Fetch API

This article demonstrates how you implement a local cache of fetched requests so that if done repeatedly it reads from session storage instead. The advantage of this is that you don’t need to have custom code for each resource you want cached. Follow along if you want to look really cool at your next JavaScript d...

Building Real-time Apps with Websockets & Server-Sent Events

This article was peer reviewed by Craig Bilner and Dan Prince. Thanks to all of SitePoint’s peer reviewers for making SitePoint content the best it can be! An important part of writing rich internet applications is reacting to data changes. Consider the following quote by Guillermo Rauch, taken from his 2014 Braz...

Sinon Tutorial: JavaScript Testing with Mocks, Spies & Stubs

This article was peer reviewed by Mark Brown and MarcTowler. Thanks to all of SitePoint’s peer reviewers for making SitePoint content the best it can be! One of the biggest stumbling blocks when writing unit tests is what to do when you have code that’s non-trivial. [author_more] In real life projects, code...

Developing Angular Apps without a Back End Using MockBackend

In this article, we show how to develop apps with the Angular 2 MockBackend class, providing a way for front-end teams to become independent of the back end, and a useful interface that reduces the risk of structural changes. Getting your front-end and back-end teams up to full speed is certainly something each company...