简体   繁体   English

谷歌将从外部 php 文件中的 jquery .load() 抓取链接

[英]Will google crawl link from jquery .load() from external php file

This is my jQuery这是我的 jQuery

$(document).ready(function() {
  $('#name').load('file.php?query=<?php echo urlencode($query); ?>', function() {
    $('#loading').hide();
  });
});

after the initial html loads it then loads the content from file.php into the div with the id=name.在初始 html 加载后,然后将 file.php 中的内容加载到 id=name 的 div 中。 this enalbes me to show a loading image while the slow moving content loads.这使我能够在缓慢移动的内容加载时显示加载图像。 its slow because it uses a few different json apis to get its content.它很慢,因为它使用一些不同的 json api 来获取其内容。 now, file.php has a bunch of different links on it.现在,file.php 上有一堆不同的链接。 will google follow those links to other pages.谷歌会跟随这些链接到其他页面。 or will google only follow the links on the initial loading of the webpages html?还是 google 只会跟踪网页 html 初始加载时的链接?

i ask this because the dynamically loaded content loaded with jquery doesn show up in the webpages source code when i look at it with my browser.我问这个是因为当我用浏览器查看时,用 jquery 加载的动态加载的内容不会显示在网页源代码中。

No Google will not see that content.没有谷歌不会看到该内容。 Google does not run any client side javascript, so the content above will never be loaded. Google 不运行任何客户端 javascript,因此永远不会加载上述内容。

I believe that if you add an empty anchor to your page, it will be found by Google, but of course, won't show up to your viewers.我相信,如果您在页面上添加一个空锚点,它会被 Google 找到,但当然不会显示给您的浏览者。

In my case, I do a PHP scandir() to dynamically create a list of files:就我而言,我执行 PHP scandir()来动态创建文件列表:

echo "<li rel=$curr_name>".$curr_name."</li>\n";

The viewer sees the list and can click on each item.查看者会看到列表并可以单击每个项目。 The jQuery click() function then gets added to each <li> and uses the rel 's value to do its thing (replacing a div with the content of the page). jQuery click()函数然后被添加到每个<li>并使用rel的值来做它的事情(用页面的内容替换一个div )。

Now, if we add an empty anchor to the mix:现在,如果我们在混合中添加一个空的锚点:

echo "<li rel=$curr_name>".$curr_name."<a href=\".$curr_path."\"></a></li>\n";

the user still sees the same list, and the jQuery will still do its thing.用户仍然看到相同的列表,jQuery 仍然会做它的事情。 BUT, there will also be an anchor to each of the files that Google will find and follow.但是,Google 将找到并跟踪的每个文件也将有一个锚点。

I couldn't find anything that says a search engine would penalize you for this.我找不到任何说搜索引擎会因此而惩罚您的内容。 And if you're worried, you could always wrap it around an image.如果您担心,您可以随时将其包裹在图像周围。

@jhanifen is right @jhanifen 是对的

However, your jquery does not look right, it should not have php in it but instead should be javascript and the backend file will take care of the rest, maybe something like this...但是,您的 jquery 看起来不正确,它不应该包含 php,而应该是 javascript,后端文件将处理其余部分,也许是这样的......

$(document).ready(function() {
  query = 'SELECT * FROM `table`';
  $('#name').load('file.php?query=' + escape(query), function() {
    $('#loading').hide();
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM