GET is basically used for getting your data from the server.
jQuery $.get() function request data from the server using HTTP GET.
Syntax: $.get(url,CallBack);
url: A string contains the url, to which request is send.
CallBack: a function which execute when the request succeeds.
Example:
$.get("\a.php?id=test",function(data)
{
alert("Success. Data: " + data);
});
Full Example:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn").click(function(){
$("#result").html("Please Wait.............");
$.get("/test.php",function(data){
$("#result").html(data);
});
});
});
</script>
</head>
<body>
<div id="result"></div>
<br />
<input type="button" id="btn" value="Click Me" />
</body>
</html>
jQuery $.get() function request data from the server using HTTP GET.
Syntax: $.get(url,CallBack);
url: A string contains the url, to which request is send.
CallBack: a function which execute when the request succeeds.
Example:
$.get("\a.php?id=test",function(data)
{
alert("Success. Data: " + data);
});
Full Example:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn").click(function(){
$("#result").html("Please Wait.............");
$.get("/test.php",function(data){
$("#result").html(data);
});
});
});
</script>
</head>
<body>
<div id="result"></div>
<br />
<input type="button" id="btn" value="Click Me" />
</body>
</html>
No comments:
Post a Comment