jQuery get() Method
jQuery get() Method
jQuery get() method loads data from the server using a HTTP GET request.
Requesting a URL
In the following example, we provide server-side coding for both PHP and Node.js, you can choose your favorite.
Example
The following is the server-side coding using PHP.
The following is the server-side coding using Node.js.
In the following client-side coding, we are not sending any data. Instead, we request a URL using jQuery get() method and receive a response.
Syntax
Parameter Values
Value | Type | Explanation |
---|---|---|
url | Required | Specifies the URL to which the 'GET' request to be sent. |
data | Optional | Specifies data to send to the server along with the request. By default, no data is sent. Note: data must be an object. |
success | Optional | Specifies a function to collect the response from the server. By default the response is ignored |
dataType | Optional | Specifies the type of data expected from the server. By default, jQuery will guess the dataType. Possible values are
|
Requesting a URL with Data
In the following example, we provide server-side coding for both PHP and Node.js, you can choose your favorite.
Example
The following is the server-side coding using PHP.
The following is the server-side coding using Node.js.
In the following client-side coding, we are requesting a URL with data using jQuery get() method and receive a response.
Response with Specified DataType
In the following example, the response from the server is expected to be a text. But it is not necessary to mention it explicitly as by default jQuery will guess the dataType by itself.
Reminder
Hi Developers, we almost covered 95% of AJAX Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in AJAX.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.