您可以通过一个文件夹中创建一个PHP文件(如果你使用PHP)和使用做到这一点将php文件作为控件(用于检索数据)。首先你必须做ajax“Post”呼叫。下面是一些代码:
$.ajax({
type: "POST",
url: "linktoyourphpfile.php",
data: { refresh: articles },
success: function(data)
{
$("#div-id-where-articles-are-generated").html(data);
}
});
});
现在正在通话后,您可以编辑PHP文件
if (isset($_POST['refresh']) {
// you do the query here. It will be an array. So you need a to define a string and accumulate whatever you need to be written. here's a sample.
$str=""; //first define the string.
$resultset //is the array of the results returned by the database. then loop through it.
foreach($resultset as $res)
{
$str=$str."<div>$res['somethin']</div>"; //you got the point.
}
//then at the end just echo the str.
echo $str;
}