jQuery Tutorial Tutorials - jQuery.get()

jQuery jQuery.get()

The jQuery.get() method in jQuery is used to load data using a HTTP GET request. This is a shorthand Ajax get function to replace the complex $.ajax.

jQuery jQuery.get() syntax

jQuery.get( url [, data ] [, success ] [, dataType ] )
jQuery.get( [settings] )
Parameter Type Description
url String request url
data PlainObject,String The data sent to the server
success Function callback function that is executed if the request succeeds.
dataType String xml, json, script, text, html(Default: Intelligent Guess )
settings PlainObject A set of key/value pairs that configure the Ajax request.

jQuery jQuery.get() example

example

Request the test.php page, but ignore the return results.

$.get( "test.php" );

example

Request the test.php page and send some additional data along (while still ignoring the return results).

$.get( "test.php", { name: "John", time: "2pm" } );

example

Alert the results from requesting test.php (HTML or XML, depending on what was returned).

$.get( "test.php", function( data ) {
  alert( "Data Loaded: " + data );
});

example

Alert the results from requesting test.cgi with an additional payload of data (HTML or XML, depending on what was returned).

$.get( "test.cgi", { name: "John", time: "2pm" } )
  .done(function( data ) {
    alert( "Data Loaded: " + data );
  });
Date:2019-08-30 02:56:11 From:www.Lautturi.com author:Lautturi