Php ajax中常见的服务器响应页面原因?
我开发了一个facebook应用程序,每个3sec使用ajax请求/响应。还有一些菜单项正在主div中加载内容。每个ajax请求都将被发送到common.php。很少有ajax非常慢。我想知道,对所有请求使用单个文件会降低性能吗 以下是速度较慢的ajax请求:Php ajax中常见的服务器响应页面原因?,php,javascript,jquery,mysql,ajax,Php,Javascript,Jquery,Mysql,Ajax,我开发了一个facebook应用程序,每个3sec使用ajax请求/响应。还有一些菜单项正在主div中加载内容。每个ajax请求都将被发送到common.php。很少有ajax非常慢。我想知道,对所有请求使用单个文件会降低性能吗 以下是速度较慢的ajax请求: function FetchMore() { document.getElementById("debugger").innerHTML = "Fetch more called"; attempt++; /*
function FetchMore()
{
document.getElementById("debugger").innerHTML = "Fetch more called";
attempt++;
/*********proccessing ajax***********/
document.getElementById("bldr").style.display="";
var urlp="https://www.shopinion.net/facebook/common.php?FBUID="+fbuid+"&action=more&attempt="+attempt+"&what="+lstevt;
if(lstevt == "home" || lstevt == "rec")
{
if(complete==false)
{
complete=true;
setTimeout("Watcher()",10000);
document.getElementById("debugger").innerHTML = "Reqest send Fetch more called";
MoreAjaxReq = $.ajax({
async: true,
url: urlp,
cache: true,
success: function(data) {
complete=false;
document.getElementById("debugger").innerHTML = "Data received Fetch more";
setTimeout("getScroll()",3000);
document.getElementById("content").innerHTML +=data;
document.getElementById("content").style.opacity="1";
Tip();
$('a[rel*=facebox]').facebox({
loadingImage : 'facebox/loading.gif',
closeImage : 'facebox/closelabel.png'
})
var handler = null;
// Prepare layout options.
var options = {
autoResize: true, // This will auto-update the layout when the browser window is resized.
container: $('#content'), // Optional, used for some extra CSS styling
offset: 6, // Optional, the distance between grid items
itemWidth: 210 // Optional, the width of a grid item
};
$(document).bind('scroll', onScroll);
// Call the layout function.
handler = $('#tiles li');
handler.wookmark(options);
$('a[rel*=facebox]').facebox({
loadingImage : 'facebox/loading.gif',
closeImage : 'facebox/closelabel.png'
})
document.getElementById("bldr").style.display="none";
//FB.Canvas.scrollTo(0,400);
setTimeout("Trick87()",3000);
}
});
}
//
请帮助我如何提高响应时间?
非常感谢advanced。哦,有很多方法可以提高性能。我会列举一些
- 在服务器端缓存数据
- 最小化响应中的内容
- 如果第一个请求尚未成功,您可能不必获取更多数据
- 使用尽可能少的数据库调用