轮播外文字使网站保持响应

时间:2018-12-15 11:16:18

标签: javascript php html css carousel

我有一个轮播(基于https://codepen.io/dobladov/pen/kXAXJx),该轮播从API加载图像,并且当您单击其他图像或“上一个”或“下一个”按钮时,该轮播会更改图像。有很多示例将文本放入轮播div上的图片中,但我在div之外没有看到它们,例如作为屏幕截图下方的段落。

*Screenshot*

有没有一种方法可以使按钮与文本相对应?因此,如果您单击下一步按钮或转到第5张图片,则当前文本是轮播中的第4张图片。

[ AH00558: httpd:  Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs ] 

1 个答案:

答案 0 :(得分:1)

问题是,当前,描述是通过回显<p><?php echo $bio4; ?></p>从服务器上检索到的,但是轮播在页面上运行,而没有对服务器的任何其他请求,因此描述永远不会改变。

您应该在单击按钮时向服务器执行异步请求,以便在不重新加载页面的情况下更新下一部电影的描述。

以下是使用JQuery的AJAX请求的示例:

$.ajax({ url: '/yourfile.php', //the file that echoes the descriptions
         data: {movieId: 5}, //ask for the desired description
         type: 'post', //specify the request type: GET/POST
         success: function(output) {
                     // code here to update the description
                  }
});

很显然,您还需要修改php文件,以便接受来自ajax调用的数据并返回所需的输出

  

有关AJAX的W3C学校的电话:   https://www.w3schools.com/xml/ajax_intro.asp

     

如何使用jquery执行ajax请求:   http://api.jquery.com/jquery.ajax/

玩得开心!

相关问题