jQuery प्राप्त करें () विधि :
उदाहरण
किसी पृष्ठ पर 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:
|