1

it turns out my website has different sections loaded by ajax. I would like for example the contact section to share on facebook, but there is no way to do this since they always shared the index.

The url of my web when ajax load content are well

www.example.com/#contacto

The button that loads ajax content:

<a href="#contacto" onClick="cargarbio('ficha.php','contenido-texto')">CONTACTO</a>

Ajax code:

 function nuevoAjax(){
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

// Función para cargar los contenidos de forma asíncrona.
// + pagina: fichero cuyo contenido queremos cargar.
// + identidicador del elemento en el que se cargará el nuevo contenido.
function cargarbio(pagina,destino){
var contenedor;
var ajax;

contenedor = document.getElementById(destino);
ajax = nuevoAjax();
ajax.open("GET", pagina, true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText;



//do Ajaxy stuff here to insert new content into hidden div 'foo' FUN

FB.XFBML.parse(document.getElementById('contenido-texto'), function() {        
    document.getElementById('yourContent').innerHTML += document.getElementById('contenido-texto').innerHTML;
});
//FUN


}
}
ajax.send(null);
}
pTRONICA
  • 59
  • 10

1 Answers1

1

For dynamic content, you'll have to use a pre-render service such as http://prerender.io, because the Facebook Scraper doesn't interpret JS code. Hence, the behaviour is how you described...

See

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • It is a payment alternative. Is not there some other way? Could you tell me how you use this site? Sample Page: http://royalbloodband.com/news – pTRONICA Jul 31 '15 at 08:29