jQuery get() Method

event.preventDefault() and return false

jQuery get() method sends an HTTP GET request to a page load data from the server back.

If any request with jQuery.get() method returns an error code then it will fail without notification unless the script has also called the global .ajaxError() method. In other side, as of jQuery 1.5, the .error() method of the jqXHR object is returned by jQuery.get() which is also available for error handling.

jQuery get() example:

$("button").click(function(){
$.get("ajax.php", function(data, status){
console.log("Data: " + data + " " + "Status: " + status);
});
});

You can pass some additional parameters there:

$.get("ajax.php", { name:"John", age:"35" });

For jquery reference click here.

Leave a Reply

Your email address will not be published. Required fields are marked *