---
title: "Fetch the JSON data from the server through jQuery"  
description: "Fetch the JSON data from the server through jQuery"  
author: "Ethan Karla"  
published: 2021-07-28  
updated: 2023-06-14  
canonical: https://www.mindstick.com/forum/156656/fetch-the-json-data-from-the-server-through-jquery  
category: "jquery"  
tags: ["jquery"]  
reading_time: 2 minutes  

---

# Fetch the JSON data from the server through jQuery

How to [fetch](https://www.mindstick.com/forum/156159/what-is-google-fetch) the [JSON data](https://www.mindstick.com/forum/782/how-to-send-request-amp-amp-response-from-json-data-using-asp-dot-net) from the [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) through jQuery?

## Replies

### Reply by Aryan Kumar

Sure, here is an example of how to fetch [JSON](https://www.mindstick.com/forum/34446/convert-json-string-to-object) [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) from the server through jQuery:

Code snippet

```plaintext
// The URL of the JSON data
var url = 'https://example.com/data.json';

// The success callback function
function success(data) {
  // Do something with the data
}

// The error callback function
function error(xhr, textStatus, errorThrown) {
  // Handle the error
}

// Fetch the data
$.getJSON(url, success, error);
```

The getJSON() method takes three arguments: the URL of the JSON data, the success callback function, and the error callback function. The success callback function will be called when the data is successfully fetched. The error callback function will be called if an error occurs.

In this example, the success callback function will simply print the data to the console. You can do whatever you want with the data in your success callback function.

Here is an example of how to use the data in the success callback function:

Code snippet

```plaintext
// The success callback function
function success(data) {
  // Loop through the data
  for (var i = 0; i < data.length; i++) {
    // Do something with the data
  }
}
```

You can also use the data in the DOM. For example, you could use it to populate a table or list.

Here is an example of how to use the data to populate a table:

Code snippet

```plaintext
// The success callback function
function success(data) {
  // Create a table
  var table = document.createElement('table');

  // Loop through the data
  for (var i = 0; i < data.length; i++) {
    // Create a row
    var row = table.insertRow(i);

    // Add the data to the row
    for (var j = 0; j < data[i].length; j++) {
      // Create a cell
      var cell = row.insertCell(j);

      // Add the data to the cell
      cell.innerHTML = data[i][j];
    }
  }

  // Append the table to the DOM
  document.body.appendChild(table);
}
```


---

Original Source: https://www.mindstick.com/forum/156656/fetch-the-json-data-from-the-server-through-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
