XML - HttpRequest in Hindi




XMLHttpRequest ऑब्जेक्ट का इस्तेमाल वेब सर्वर से डेटा का अनुरोध करने के लिए किया जा सकता है सभी modern ब्राउज़रों में एक सर्वर से डेटा का अनुरोध करने के लिए एक built-in XMLHttpRequest ऑब्जेक्ट होता है।

XMLHttpRequest, जिसे XHR भी कहा जाता है, एक application प्रोग्राम इंटरफ़ेस (एपीआई) है जिसका उपयोग माइक्रोसॉफ्ट ने पहली बार अपने इंटरनेट explorer वेब ब्राउजर के संस्करण 5.0 में activeX ऑब्जेक्ट के रूप में कार्य करने के लिए किया था तब से, XHR को mozilla के versions 7.0 और netscape के संस्करणों और versions 1.2 और एप्पल ब्राउज़र से सफारी के रूप में जाना जाता है।

XML HttpRequest के कुछ operations नीचे दिए जा रहे है आप उनको follow कर सकते है

  • यह background मे client से data को Send करता है।

  • यह server से data को प्राप्त करता है।

  • इसे पुनः reload किए बिना webpage पर अपडेट किया जा सकता है।

Example Code

<!DOCTYPE html>
<html>
<body>
<h2>XMLHttpRequest Object
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</div>
<script>
function loadXMLDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "xmlhttp_info.txt", true);
  xhttp.send();
}
</script>
</body>
</html>

Example Result

XMLHttpRequest Object