jQuery get() နည်းလမ်း
ဥပမာ
စာမျက်နှာတစ်ခုသို့ HTTP GET တောင်းဆိုချက်ကို ပေးပို့ပြီး ရလဒ်ကို ပြန်လည်ရယူပါ-
$("button").click(function(){
$.get("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
$.get() နည်းလမ်းသည် HTTP GET တောင်းဆိုမှုကို အသုံးပြု၍ ဆာဗာမှဒေတာကို တင်ပါသည်။
ဥပမာများ
"test.php" ကို တောင်းဆိုသော်လည်း ရလဒ်များကို လျစ်လျူရှုပါ-
$.get("test.php");
"test.php" ကို တောင်းဆိုပြီး တောင်းဆိုချက်နှင့်အတူ နောက်ထပ်ဒေတာအချို့ကို ပေးပို့ပါ (ပြန်ရလာဒ်များကို လျစ်လျူရှုပါ)။
$.get("test.php", { name:"Donald", town:"Ducktown" });
"test.php" ကို တောင်းဆိုပြီး ဆာဗာသို့ ဒေတာအခင်းအကျင်းများကို ပေးပို့ပါ (ပြန်ရလာဒ်များကို လျစ်လျူရှုပါ)။
$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });
"test.php" ကို တောင်းဆိုပြီး တောင်းဆိုမှု၏ရလဒ်ကို သတိပေးပါ-
$.get("test.php", function(data){
alert("Data: " + data);
});
အထားအသို
$.get(URL,data,function(data,status,xhr),dataType)
Parameter | Description |
---|---|
URL | Required. Specifies the URL you wish to request |
data | Optional. Specifies data to send to the server along with the request |
function(data,status,xhr) | Optional. Specifies a function to run if the request succeeds Additional parameters:
|
dataType | Optional. Specifies the data type expected of the server response. By default jQuery performs an automatic guess. Possible types:
|