Back to the 2024 paper

Module III — Basics of Web Programming

20242m

Which method is used in JavaScript to send a request to the server asynchronously? (i) fetch() (ii) XMLHttpRequest() (iii) $.get() (iv) send()

Worked SolutionAI Assisted

Answer: (i) fetch()

fetch() is the modern, Promise-based API for asynchronous HTTP requests:

const res = await fetch('/api/data');
const data = await res.json();

XMLHttpRequest is the older async mechanism, and $.get() is a jQuery library wrapper. The built-in native method to prefer is fetch().

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.