Fra*_*esc 2 php mysql jquery-plugins live
是否有任何jQuery插件可以使用PHP 从Twitter主页面创建类似实时源的内容,这是从MySQL数据库获取数据?
如何成为PHP文件?
谢谢.
你真的不需要一个插件,你可以使用jQuery轻松创建类似的东西来对PHP MySQL提要进行AJAX调用
创建一个脚本,使重复出现的Ajax调用使用的setTimeout() ,然后使用添加新的发现结果进容器.prepend()
HTML
<html>
<head><title>Tweets</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style>
#tweets {
width: 500px;
font-family: Helvetica, Arial, sans-serif;
}
#tweets li {
background-color: #E5EECC;
margin: 2px;
list-style-type: none;
}
.author {
font-weight: bold
}
.date {
font-size: 10px;
}
</style>
<script>
jQuery(document).ready(function() {
setInterval("showNewTweets()", 1000);
});
function showNewTweets() {
$.getJSON("feed.php", null, function(data) {
if (data != null) {
$("#tweets").prepend($("<li><span class=\"author\">" + data.author + "</span> " + data.tweet + "<br /><span class=\"date\">" + data.date + "</span></li>").fadeIn("slow"));
}
});
}
</script>
</head>
<body>
<ul id="tweets"></ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
PHP
<?php
echo json_encode(array( "author" => "someone",
"tweet" => "The time is: " . time(),
"date" => date('l jS \of F Y h:i:s A')));
?>
Run Code Online (Sandbox Code Playgroud)