模仿新浪微博换一换
程序员文章站
2022-06-01 18:50:22
...
1. [代码]change.js
//change.js $(document).ready(function(){ var url = "change_doc.php"; showFirstPage(url); }); function showFirstPage(serverUrl){ var url = serverUrl+"?fuckie="+Math.random(); $.get( url, function(data){ $(".change_doc").html(data); } ); }
2. [代码]index.php
//index.php <script type="text/javascript" src="js_change/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js_change/change.js" ></script> <p class="change_doc"></p>
3. [代码]change_doc.php
<?php include 'connect.php'; function change_doc() { $Row = @mysql_query("SELECT * FROM countries ORDER BY rand() DESC LIMIT 3"); $Html = ""; $Html .= '<p class="right_r_c">'; $Html .= ' <p class="right_r_c_t1" ><span class="right c_73a6eb right_c_h"><a onclick="showFirstPage(\'change_doc.php\'); " href="javascript: void(0);">换一换</a></span>'; $Html .= ' </p>'; $Html .= ' <p class="clear"></p>'; $Html .= ' <p id="change_one">'; while ($mesList = @mysql_fetch_array($Row)) { $Html .= ' <p class="right_c_c">'; $Html .= ' <p><a href="#">' . $mesList['value'] . '</a></p>'; $Html .= ' </p>'; } $Html .= ' </p>'; $Html .= '</p>'; return $Html; } echo change_doc(); ?>