An object of XMLHttpRequest is used for asynchronous communication between client and server.
It performs following operations:
- Sends data from the client in the background
- Receives the data from the server
- Updates the webpage without reloading it.
Properties of XMLHttpRequest object
The common properties of XMLHttpRequest object are as follows:
Property | Description |
---|---|
onReadyStateChange | It is called whenever readystate attribute changes. It must not be used with synchronous requests. |
readyState | represents the state of the request. It ranges from 0 to 4.0 UNOPENED open() is not called.1 OPENED open is called but send() is not called.2 HEADERS_RECEIVED send() is called, and headers and status are available.3 LOADING Downloading data; responseText holds the data.4 DONE The operation is completed fully. |
reponseText | returns response as text. |
responseXML | returns response as XML |
https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-4699858549023382&output=html&h=280&slotname=6746133113&adk=3355109626&adf=417195216&pi=t.ma~as.6746133113&w=336&lmt=1705713577&rafmt=12&format=336×280&url=https%3A%2F%2Fwww.javatpoint.com%2Funderstanding-xmlhttprequest&wgl=1&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTA2LjAuNDk5OC4yOCIsbnVsbCwwLG51bGwsIjY0IixbWyJOb3RfQSBCcmFuZCIsIjguMC4wLjAiXSxbIkNocm9taXVtIiwiMTIwLjAuNjA5OS4yMDAiXSxbIk9wZXJhIiwiMTA2LjAuNDk5OC4yOCJdXSwxXQ..&dt=1705713577838&bpp=17&bdt=737&idt=77&shv=r20240117&mjsv=m202401110101&ptt=9&saldr=aa&abxe=1&cookie=ID%3D6a58edbf381035a2%3AT%3D1705376916%3ART%3D1705666584%3AS%3DALNI_MYhtG7NEIEl6wakp3sW0Q-wliev1A&gpic=UID%3D00000d426f0b5db2%3AT%3D1705376916%3ART%3D1705666584%3AS%3DALNI_MYYjPhUeFEJLavjTcpj4x5Yrsoi-A&correlator=6163355078968&frm=20&pv=2&ga_vid=1571275994.1705281890&ga_sid=1705713295&ga_hid=1343013675&ga_fc=1&u_tz=-480&u_his=4&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=24&u_sd=1&dmc=8&adx=246&ady=1092&biw=1297&bih=644&scr_x=0&scr_y=0&eid=95320239%2C44759875%2C44759926%2C44759837%2C95322180%2C95320892%2C95321626%2C95322165%2C95322325&oid=2&pvsid=3677301489723209&tmod=325684013&uas=0&nvt=1&ref=https%3A%2F%2Fwww.javatpoint.com%2Fajax-technologies&fc=896&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C728%2C1312%2C644&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=256&bc=31&bz=1.04&psd=W251bGwsbnVsbCxudWxsLDNd&ifi=1&uci=a!1&btvi=1&fsb=1&dtd=135
Methods of XMLHttpRequest object
The important methods of XMLHttpRequest object are as follows:
Method | Description |
---|---|
void open(method, URL) | opens the request specifying get or post method and url. |
void open(method, URL, async) | same as above but specifies asynchronous or not. |
void open(method, URL, async, username, password) | same as above but specifies username and password. |
void send() | sends get request. |
void send(string) | send post request. |
setRequestHeader(header,value) | it adds request headers. |
Leave a Reply