在我的应用程序中我使用Jquery $.post
方法到我正在进行Mysql DB调用的PHP页面,并且返回我在循环中创建div,最后将它返回到Jquery $ .post方法并附加输出到HTML div标签。我有8个不同的区域,对于每个区域,我使用单独的Jquery $.post
方法向该PHP文件发送不同的参数。一切正常,但当我尝试刷新页面3-5次(快速按下刷新按钮)页面中断时,如果我保持fiddler2打开显示:
"[Fiddler] ReadResponse() failed: The server did not return a response for this request.Server returned 0 bytes."
如果fiddler2未打开,则会显示:
"The connection was reset
The connection to the server was reset while the page was loading."
我正在使用OOP PHP连接到Mysql,检查是否有实时连接,查询执行后我也关闭了连接。是因为从单独的Jquery $ .post方法到服务器的单独调用太多了吗?
Jquery $ .post方法:
$.post('app_code/pageOperations/homepage.php', {
articleTypeID: 1, //param for PHP page
articleDate: today, //var holds today's date, param for PHP page
position: "body" //param for PHP page
},
function(output){ $("#politicsTop5").html(output);
}
);
我有8种不同数据参数的方法。
PHP代码
if($position == "body"){
$_page_interface = new page_interface();
$result = $_page_interface->getArticleBody( $articleTypeID, $articleDate );
while($row = $result->fetch_assoc())
{
echo "<div id='politics'>
<div class='article-item alert alert-success'>
<figure class='pull-left'><img src='".$row['speaker_img_link']."' alt='".$row['speaker_designation']." ".$row['speaker_name']."' /></figure>
<div class='pull-right article-content'>
<h4><a href='single_article.php?aId=".$row['article_id']."&typeId=".$row['article_type_id']."' title=''>".$row['article']."<br>- <b>".$row['speaker_designation']." ".$row['speaker_name']."</b></a></h4>
<p class='article-meta'><b>".$row['TotalUp']."</b> <i class='icon-thumbs-up'></i> | <b>".$row['TotalDown']."</b> <i class='icon-thumbs-down'></i> | <b>".$row['TotalComment']."</b> <i class='icon-pencil'></i></p>
</div>
</div>
</div>";
}
}
所有这8个Jquery方法都使用不同的参数调用此PHP块。 一切正常,但经过几次刷新后,数据无法加载。有人能帮帮我吗?提前谢谢。
PHP代码块编辑:
if($position == "body"){
$_page_interface = new page_interface();
$result = $_page_interface->getArticleBody( $articleTypeID, $articleDate );
while($row = $result->fetch_assoc())
{
echo "<div class='politics'>
<div class='article-item alert alert-success'>
<figure class='pull-left'><img src='".$row['speaker_img_link']."' alt='".$row['speaker_designation']." ".$row['speaker_name']."' /></figure>
<div class='pull-right article-content'>
<h4><a href='single_article.php?aId=".$row['article_id']."&typeId=".$row['article_type_id']."' title=''>".$row['article']."<br>- <b>".$row['speaker_designation']." ".$row['speaker_name']."</b></a></h4>
<p class='article-meta'><b>".$row['TotalUp']."</b> <i class='icon-thumbs-up'></i> | <b>".$row['TotalDown']."</b> <i class='icon-thumbs-down'></i> | <b>".$row['TotalComment']."</b> <i class='icon-pencil'></i></p>
</div>
</div>
</div>";
}
}