XMLHttpRequest ऑब्जेक्ट _
XMLHttpRequest ऑब्जेक्ट के साथ आप पूरे पृष्ठ को पुनः लोड किए बिना, वेब पेज के कुछ हिस्सों को अपडेट कर सकते हैं।
इसे स्वयं आज़माएं - उदाहरण
बनाएं, और एक TXT फ़ाइल से डेटा पुनर्प्राप्त करें।
पुनर्प्राप्त करें संसाधन (फ़ाइल) की शीर्षलेख जानकारी पुनर्प्राप्त करें।
पुनर्प्राप्त करें संसाधन (फ़ाइल) की विशिष्ट शीर्षलेख जानकारी पुनर्प्राप्त करें।
करें एक वेब पेज एक वेब सर्वर के साथ कैसे संचार कर सकता है जबकि एक उपयोगकर्ता इनपुट फ़ील्ड में वर्ण टाइप करता है।
करें एक वेब पेज XMLHttpRequest ऑब्जेक्ट के साथ डेटाबेस से जानकारी कैसे प्राप्त कर सकता है।
से डेटा पुनर्प्राप्त करने के लिए XMLHttpRequest बनाएं और डेटा को HTML तालिका में प्रदर्शित करें।
XMLHttpRequest ऑब्जेक्ट
XMLHttpRequest ऑब्जेक्ट का उपयोग पर्दे के पीछे सर्वर के साथ डेटा का आदान-प्रदान करने के लिए किया जाता है।
XMLHttpRequest ऑब्जेक्ट डेवलपर्स का सपना है , क्योंकि आप यह कर सकते हैं:
- पृष्ठ को पुनः लोड किए बिना वेब पृष्ठ को अपडेट करें
- पेज लोड होने के बाद सर्वर से डेटा का अनुरोध करें
- पेज लोड होने के बाद सर्वर से डेटा प्राप्त करें
- पृष्ठभूमि में सर्वर को डेटा भेजें
XMLHttpRequest ऑब्जेक्ट मेथड्स
Method | Description |
---|---|
abort() | Cancels the current request |
getAllResponseHeaders() | Returns header information |
getResponseHeader() | Returns specific header information |
open(method,url,async,uname,pswd) | Specifies the type of request, the URL, if the request should be handled asynchronously or not, and other optional attributes of a request
method: the type of request: GET or POST url: the location of the file on the server async: true (asynchronous) or false (synchronous) |
send(string) | send(string) Sends the request off to the server. string: Only used for POST requests |
setRequestHeader() | Adds a label/value pair to the header to be sent |
XMLHttpRequest वस्तु गुण
Property | Description |
---|---|
onreadystatechange | Stores a function (or the name of a function) to be called automatically each time the readyState property changes |
readyState | Holds the status of the XMLHttpRequest. Changes from 0 to 4: 0: request not initialized 1: server connection established 2: request received 3: processing request 4: request finished and response is ready |
responseText | Returns the response data as a string |
responseXML | Returns the response data as XML data |
status | Returns the status-number (e.g. "404" for "Not Found" or "200" for "OK") |
statusText | Returns the status-text (e.g. "Not Found" or "OK") |