{"id":238,"date":"2020-12-12T19:41:24","date_gmt":"2020-12-12T19:41:24","guid":{"rendered":"https:\/\/codeflarelimited.com\/blog\/?p=238"},"modified":"2021-05-31T05:21:35","modified_gmt":"2021-05-31T04:21:35","slug":"working-with-xmlhttprequest","status":"publish","type":"post","link":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/","title":{"rendered":"Working With XMLHttpRequest"},"content":{"rendered":"\n<p>The XMLHttpRequest is a <a href=\"https:\/\/codeflarelimited.com\/catalogue\/frontend\" target=\"_blank\" rel=\"noreferrer noopener\">Javascript <\/a>object that is used to interact with web servers.<\/p>\n\n\n\n<p>The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading the entire page.<\/p>\n\n\n\n<p>Now, XMLHttpRequest is not just limited to XML alone. It can be used to retrieve any type of data, especially from an <a rel=\"noreferrer noopener\" href=\"https:\/\/codeflarelimited.com\/blog\/2020\/12\/11\/working-with-fetch-api\/\" target=\"_blank\">API<\/a>.<\/p>\n\n\n\n<p class=\"has-large-font-size\"><strong>Let us see an example of how it works.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript\">let xhr = new XMLHttpRequest(); \/\/Invoke an instance\nxhr.onload = success; \/\/call success function\nxhr.onerror = error; \/\/call error function\nxhr.open('GET',' fetch('https:\/\/api.github.com\/repos\/javascript-tutorial\/en.javascript.info\/commits'); \/\/initiate a request\nxhr.send(); \/\/send the request\n\n\/\/Handle success\nfunction success(){\nlet data = JSON.parse(this.responseText);\nconsole.log(data);\n}\n\n\/\/Handle error\nfunction error(err){\nconsole.log(`Request failed: ${err}`);\n}<\/code><\/pre>\n\n\n\n<p><strong>Result:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"510\" height=\"466\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/Screenshot-2020-12-11-at-10.10.18.png\" alt=\"\" class=\"wp-image-233\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/Screenshot-2020-12-11-at-10.10.18.png 510w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/Screenshot-2020-12-11-at-10.10.18-300x274.png 300w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" href=\"https:\/\/codeflarelimited.com\/catalogue\" target=\"_blank\" rel=\"noreferrer noopener\">BEGIN your software development journey<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The XMLHttpRequest is a Javascript object that is used to interact with web servers. The XMLHttpRequest() is a<\/p>\n","protected":false},"author":1,"featured_media":239,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11],"tags":[69,68],"class_list":["post-238","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-fetch","tag-xmlhttprequest"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Working With XMLHttpRequest<\/title>\n<meta name=\"description\" content=\"The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working With XMLHttpRequest\" \/>\n<meta property=\"og:description\" content=\"The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/codeflretech\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-12T19:41:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-31T04:21:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"codeflare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeflaretech\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/\"},\"author\":{\"name\":\"codeflare\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\"},\"headline\":\"Working With XMLHttpRequest\",\"datePublished\":\"2020-12-12T19:41:24+00:00\",\"dateModified\":\"2021-05-31T04:21:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/\"},\"wordCount\":79,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/space3.jpg\",\"keywords\":[\"fetch\",\"xmlhttprequest\"],\"articleSection\":[\"javascript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/\",\"name\":\"Working With XMLHttpRequest\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/space3.jpg\",\"datePublished\":\"2020-12-12T19:41:24+00:00\",\"dateModified\":\"2021-05-31T04:21:35+00:00\",\"description\":\"The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#primaryimage\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/space3.jpg\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/space3.jpg\",\"width\":1200,\"height\":668,\"caption\":\"ict training in abuja\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/working-with-xmlhttprequest\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"javascript\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Working With XMLHttpRequest\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"name\":\"\",\"description\":\"Sustainable solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\",\"name\":\"Codeflare Limited\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"width\":1040,\"height\":263,\"caption\":\"Codeflare Limited\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\",\"name\":\"codeflare\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"caption\":\"codeflare\"},\"description\":\"Latest tech news and coding tips.\",\"sameAs\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\",\"https:\\\/\\\/facebook.com\\\/codeflretech\",\"https:\\\/\\\/instagram.com\\\/codeflaretech\",\"https:\\\/\\\/x.com\\\/codeflaretech\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1\"],\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/author\\\/watcher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Working With XMLHttpRequest","description":"The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/","og_locale":"en_US","og_type":"article","og_title":"Working With XMLHttpRequest","og_description":"The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading","og_url":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/","article_author":"https:\/\/facebook.com\/codeflretech","article_published_time":"2020-12-12T19:41:24+00:00","article_modified_time":"2021-05-31T04:21:35+00:00","og_image":[{"width":1200,"height":668,"url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg","type":"image\/jpeg"}],"author":"codeflare","twitter_card":"summary_large_image","twitter_creator":"@codeflaretech","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#article","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/"},"author":{"name":"codeflare","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a"},"headline":"Working With XMLHttpRequest","datePublished":"2020-12-12T19:41:24+00:00","dateModified":"2021-05-31T04:21:35+00:00","mainEntityOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/"},"wordCount":79,"commentCount":0,"publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg","keywords":["fetch","xmlhttprequest"],"articleSection":["javascript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/","url":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/","name":"Working With XMLHttpRequest","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#primaryimage"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg","datePublished":"2020-12-12T19:41:24+00:00","dateModified":"2021-05-31T04:21:35+00:00","description":"The XMLHttpRequest() is a Javascript function that makes it possible for developers to fetch XML data from the database without reloading","breadcrumb":{"@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#primaryimage","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg","width":1200,"height":668,"caption":"ict training in abuja"},{"@type":"BreadcrumbList","@id":"https:\/\/codeflarelimited.com\/blog\/working-with-xmlhttprequest\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeflarelimited.com\/blog\/"},{"@type":"ListItem","position":2,"name":"javascript","item":"https:\/\/codeflarelimited.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"Working With XMLHttpRequest"}]},{"@type":"WebSite","@id":"https:\/\/codeflarelimited.com\/blog\/#website","url":"https:\/\/codeflarelimited.com\/blog\/","name":"","description":"Sustainable solutions","publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeflarelimited.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codeflarelimited.com\/blog\/#organization","name":"Codeflare Limited","url":"https:\/\/codeflarelimited.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","width":1040,"height":263,"caption":"Codeflare Limited"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a","name":"codeflare","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","caption":"codeflare"},"description":"Latest tech news and coding tips.","sameAs":["https:\/\/codeflarelimited.com\/blog","https:\/\/facebook.com\/codeflretech","https:\/\/instagram.com\/codeflaretech","https:\/\/x.com\/codeflaretech","https:\/\/www.youtube.com\/channel\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1"],"url":"https:\/\/codeflarelimited.com\/blog\/author\/watcher\/"}]}},"jetpack_featured_media_url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/12\/space3.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/comments?post=238"}],"version-history":[{"count":4,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":649,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/238\/revisions\/649"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media\/239"}],"wp:attachment":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media?parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/categories?post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/tags?post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}