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:
|