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.

Based on United States, Jacob Frazier is a skilled JavaScript developer with over 8 years of experience. He is passionate about change and trying new things, both professionally and personally. He loves startups and is extremely proactive.

You may like:  How to check checkbox with jQuery?

Leave a Reply

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