How to fetch only sections of specific HTML areas from an external page using AJAX ? (original) (raw)

Last Updated : 23 Jul, 2025

In this article, we will see how to fetch the specific sections of an HTML file from an external page using AJAX, along with understanding their basic implementation through the illustrations.

Suppose we have an HTML page and this page contains different sections. Each Section can be identified using the class name or ID. Our task is to use Ajax in the External HTML page and fetch the content of the first HTML page into the External HTML Page. Here, we have 2 HTML pages, where the specific portion of code from HTML page 1 is getting fetched by HTML page 2. The below example depicts the concept of fetching only sections of specific HTML areas from an external page.

To accomplish this task, the jQuery Load() functionwill be used that helps to load data from the server and returned it to the selected element without loading the whole page.

Syntax:

$(selector).load(URL, data, callback);

This function can load data from files like HTML, TXT, XML, and JSON.

Approach: To perform this task, we will follow the below steps:

Example 1: In this example, we will be fetching the first

element of the index.html page using the External.html page.