page app (E-commerce website).
Please suppose I have anchor tags with href="url" for SEO, but I want to get new HTML content (a section of page) from the server by SSR (server side rendering).
Example:
In this example I want to replace new HTML content (static page provided by server by ssr) inside div, but its trigger is anchor tag.
<a href="url" onClick="myAjaxFunction(url)">text</a>
<div id="my-ajax-html-answer"></div>
<script>
$(document).ready(function(){
$('a').click(function(e){
e.preventDefault(); //disable href for all anchor tags
});
});
function myAjaxFunction(url){
$("#my-ajax-html-answer").load(url);
}
</script>
Is this approach true for SEO?
No answer?😒
If you're assuming that the crawler doesn't have js support (which is possible) this solution won't work And if it does, it can just crawl the spa 🤔
I did not understand what you mean exactly. I'm a java developer not javascript. I think with my scenario, google crawler can read anchor tag (because they have href attribute). But I'm disabling them by javascript code (`preventDefault`). Therefore I can use `onClick` in my anchor tags to use ajax. My ajax response in the server is a HTML text that will be placed instead of the selected tag in my client (here div with `my-ajax-html-answer` id). So I think this is SEO friendly. Are you agree?
Обсуждают сегодня