Cheat sheet for moving from jQuery to vanilla JavaScript | Tobias Ahlin
Thank you Tobias:
To spare you the time, Iβve compiled this practical reference guide with some of the most common jQuery patterns and their equivalents in JavaScript.
Website strategy & development
Thank you Tobias:
To spare you the time, Iβve compiled this practical reference guide with some of the most common jQuery patterns and their equivalents in JavaScript.
A sign-up form I'm working on requires multiple AJAX requests to an API on form submission. The receiving server did not like being hit with parallel requests and the operation failed with "MIME type mismatch errors" in the dev tools console. After much debugging pain, changing course to sequential calls fixed this.
The code below makes uses of Promises in jQuery to wait for ajax calls to complete before starting the next call in the sequence. All the ajax calls are made to the same API, but the data sent in the call are defined in the items array.
As most of my projects are WordPress based, the much maligned jQuery is still very much in the toolbox. Here's a nice overview of different scenarios involving Promises. The section on multiple dynamic ajax calls came in handy recently.