jQuery getJSON() Method
The getJSON() method in jQuery fetches JSON-encoded data from the server using a GET HTTP request.
Parameters: This method accepts three parameters as mentioned above and described below:
- url: It is a required parameter. It is used to specify the URL in the form of a string to which the request is sent
- data: It is an optional parameter that specifies data that will be sent to the server.
- callback: It is also an optional parameter that runs when the request succeeds.
Return Value: It returns XMLHttpRequest object.
Example: The below example illustrates the getJSON() method in jQuery.
“name”: “Tony Stark”,
“age” : “53”,
“role”: “Techincal content writer”,
“company”:”Geeks for Geeks”
Here, we get the JSON file and displays its content.