Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

How to make Googlebot to crawl correctly an Ajax URL

         

guarriman3

2:24 pm on Jun 4, 2024 (gmt 0)

10+ Year Member Top Contributors Of The Month



I created an accordion in my pages to show the name of the products in alphabetical order to help users. I inserted an Ajax function to read several URLs with the following piece of code:

e.open("GET", "https://example.com/feed.php?letter=A&id=" + myId, true);

or
e.open("GET", "https://example.com/feed.php?letter=B&id=" + myId, true);


Each URL
https://example.com/feed.php?letter=B&id=1
https://example.com/feed.php?letter=B&id=2
shows 20 links to 20 different products, and works ok for the users. The ids for each URL are taken from another JavaScript code, and the URLs are correctly created for users.

However, within my Google Search Console I find several 404 errors (one per letter), warning me that Googlebot was not able to crawl
https://example.com/feed.php?letter=B&id=
(with no value for 'id')

As I said, the accordion and the Ajax work ok in the webpages. I would like to make Googlebot to crawl correctly an Ajax URL.

not2easy

3:58 pm on Jun 4, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What do you see when you go to GSC and request rendering the URL of one of the pages where the AJAX code is used? Is there any reason they cannot access the other .js file that provides the ID numbers? I ask because I know they can use, parse and crawl AJAX linked content.

I should add, if the .js that adds the ID is activated on click only, it might be an issue.

guarriman3

1:19 pm on Jun 7, 2024 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you @not2easy

What do you see when you go to GSC and request rendering the URL of one of the pages where the AJAX code is used?

In the screenshot of the 'URL inspection', the displayed rendering does not reach the area from where Ajax is called. The HTML code is ok, and there are no alerts in 'More Info'.

Is there any reason they cannot access the other .js file that provides the ID numbers?

The ID is provided in the code within the web page

I should add, if the .js that adds the ID is activated on click only, it might be an issue.

Yes, the ID is activated only after clicking in a '+' icon. There is an 'EventListener' for clicks:
myblock.addEventListener('click', function(event) {
var myId = myblock.id