I deduce the data from the database after loading the page. Of course, the title, description is not visible, neither to the search engine nor to the parser VC (widget for share).

Now the output works like this 1) get data from the database and form json

$link=$_REQUEST['link']; $STH = $DBH->query('SELECT * from post where title_lat="'.$link.'" ORDER BY id DESC '); $STH->setFetchMode(PDO::FETCH_ASSOC); while($row = $STH->fetch()) { $data= json_encode( array( 'title'=>$row['title'], 'text_news'=>htmlspecialchars_decode($row['text']), 'image'=>'http://site.com/'.$row['image'], 'titleseo'=>"<title>".$row['seo_title']."</title>", 'description'=>"<meta name='description' content='".$row['seo_des']."' />", 'keywords'=>"<meta name='keywords' content='".$row['seo_keyword']."' />", 'vk'=>"<meta property='og:title' content='".$row['seo_title']."' /><meta property='og:image' content='http://site.com/".$row['image']."' /><meta property='vk:image' content='http://site.com/".$row['image']."' />" ) ); echo $data; } 

2) then on the page I display

 $.ajax({ type: "POST", data:"link="+link, dataType:'json', url: "output_post.php", success: function(data) { $('head').prepend(data.titleseo+data.description+data.keywords+data.vk); $(".cok_slider").css('background: fixed;','') $(".cok_slider").css({"background": "url("+data.image+")", "background-position": "fixed"}); $(".title").text(data.title); $(".content").append(data.text_news); } }); 

How can this problem be solved? If without js, but how to display information in different places of the page?

    1 answer 1

    Without JS, you can just make a php page. For example:

    index.php

     <?php $myTitle = "Заголовок страницы"; $myValue = 2; ?> <html> <head> <title><?php echo $myTitle;?></title> </head> <body> Мое значение = <?php echo $myValue;?> И еще раз - <?php echo $myValue;?> </body> </html> 

    However, I think you mean something else. Can you describe in more detail?

    • Yes, that is what I meant. it's just that your option is good, but my body is big, and supporting such a colossus is not very convenient, of course, if I don’t find any other way, I’ll create a whole page, but there is little any other solution -