我有一个报价生成器,位于http://communitychessclub.com。我希望用户能够点击报价并加载另一个随机报价而不是刷新整个页面。我怎样才能做到这一点?onClick使用“quotes.txt”中的随机文本行刷新div
<h3>
<?php $randomThings = file('quotes.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
echo $randomThings[mt_rand(0,count($randomThings)-1)];?>
</h3>
我试图科林shoens建议下面:
<div id="new-projects"></div>
<script>
$("#new-projects").load("quotes.txt");
</script>
但它装的不是一个单一的随机报价均为307个报价。
http://communitychessclub.com/test.php
我该如何解决这个问题?
使用JavaScript。 – Mathemats 2015-03-31 23:49:29
有多少报价?你能用上面的代码制作一个专用的quotes.php吗? – Drakes 2015-03-31 23:56:30
我有307个引号。是的,我可以使用PHP来回显并运行上面的代码。 – verlager 2015-04-01 00:14:52