Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
🚳 Interview Questions: Ajax implementation

#js #interview #ajax

Implement an ajax request function that supports Promise:

🍣Send a request using the XMLHttpRequest object

πŸ›Initialize the open method, configure the request method and url

🍷Add onload and onerror callback functions

πŸ§‰onload determines whether the status code is within the range of 200–300 resolve, otherwise reject

🫘onerror directly reject

πŸ₯§After the request is successful, resolve returns response, and after failure, reject reports an error.

πŸ₯ŸSupport options to configure request parameters and request body

🍱Returns a Promise object, which can be processed externally using then/catch

Analysis: Promise is used to encapsulate asynchronous ajax requests and achieve a synchronous programming style.
Please open Telegram to view this post
VIEW IN TELEGRAM