function LoadJS(fileUrl)
{
var oHead = document.getElementsByTagName('HEAD').item(0);
var oScript= document.createElement("script");
oScript.type = "text/javascript";
oScript.src=fileUrl ;
oHead.appendChild(oScript);
}
function likes()
{
LoadJS('请求数据的网址&onsuccess=getvotesuccess&t='+Math.random().toString());
}
function getvotesuccess(result)
{
list = eval(result);
for(var i=0; i<list.length; i++){
$("#vote_"+list[i].pid).html(list[i].vote_count);
}
{
var oHead = document.getElementsByTagName('HEAD').item(0);
var oScript= document.createElement("script");
oScript.type = "text/javascript";
oScript.src=fileUrl ;
oHead.appendChild(oScript);
}
function likes()
{
LoadJS('请求数据的网址&onsuccess=getvotesuccess&t='+Math.random().toString());
}
function getvotesuccess(result)
{
list = eval(result);
for(var i=0; i<list.length; i++){
$("#vote_"+list[i].pid).html(list[i].vote_count);
}
}
在js中写上这些之后还要在你请求数据的地址中调用成功返回的方法getvotesuccess,
<?php
$list = array();
$onsuccess =$_GET['onsuccess'];
echo $onsuccess.'('.json_encode($list).')';
?>