XMLHttpRequest Object _
XMLHttpRequest object ဖြင့် စာမျက်နှာတစ်ခုလုံးကို ပြန်မတင်ဘဲ ဝဘ်စာမျက်နှာ၏ အစိတ်အပိုင်းများကို အပ်ဒိတ်လုပ်နိုင်ပါသည်။
သင်ကိုယ်တိုင်စမ်းကြည့်ပါ - ဥပမာများ
ဖန်တီးပြီး TXT ဖိုင်တစ်ခုမှ ဒေတာကို ရယူပါ။
ခေါင်းစီးအချက်အလက်ကို အရင်းအမြစ် (ဖိုင်) ၏ ခေါင်းစီးအချက်အလက်ကို ရယူပါ။
ဖြင့် သီးခြားခေါင်းစီးအချက်အလက်ကို ရယူပါ အရင်းအမြစ် (ဖိုင်) ၏ သီးခြားခေါင်းစီးအချက်အလက်ကို ရယူပါ။
သုံးစွဲသူသည် ထည့်သွင်းအကွက်တွင် စာလုံးရိုက်နေစဉ် ဝဘ်စာမျက်နှာတစ်ခုသည် ဝဘ်ဆာဗာနှင့် ဆက်သွယ်နိုင်ပုံ။
မည်သို့ရယူနိုင်မည်နည်း။
ပြန်လည်ရယူရန် XMLHttp တောင်းဆိုချက်တစ်ခု ဖန်တီးပြီး XML ဖိုင်တစ်ခုမှ ဒေတာကို ရယူပြီး HTML ဇယားတစ်ခုတွင် ဒေတာကို ပြသရန်။
XMLHttpRequest Object
XMLHttpRequest object ကို နောက်ကွယ်ရှိ server တစ်ခုနှင့် data ဖလှယ်ရန်အတွက် အသုံးပြုပါသည်။
XMLHttpRequest object သည် developer များ၏ အိပ်မက် ဖြစ်သည်၊ သင်လုပ်နိုင်သောကြောင့်-
- စာမျက်နှာကို ပြန်မတင်ဘဲ ဝဘ်စာမျက်နှာကို အပ်ဒိတ်လုပ်ပါ။
- စာမျက်နှာကို တင်ပြီးနောက် ဆာဗာတစ်ခုထံမှ ဒေတာကို တောင်းဆိုပါ။
- စာမျက်နှာကို တင်ပြီးနောက် ဆာဗာတစ်ခုမှ ဒေတာကို ရယူပါ။
- နောက်ခံရှိဆာဗာသို့ ဒေတာပေးပို့ပါ။
XMLHttpRequest Object Methods
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 Object Properties
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") |