页面在哪里花费时间


Where is the page spending its time

我在页面上显示了可用的酒店房间和预订按钮。房间列表(比如5)的可用性是使用jquery async ajax检查的。在服务器端的PHP中,可用性由来自同一文件的单独curl请求处理。

现在,一旦返回房间的可用性,我们就会向用户显示一个链接,该链接是一个带有结账页面URL的锚标记。

在收到第一次可用性后,如果我试图点击链接,那么在点击后,页面会花大约20秒的时间等待我不知道的东西。我可以在控制台中看到,其他尚未给出结果的ajax请求已经中止。现在,这个页面在点击后进入结账页面之前的时间在哪里。

一旦第一个链接被点击,其余的请求就会自动中止。现在在浏览器中,我可以看到加载图标,但在接下来的20秒内什么都没有发生。20秒后,我看到了结账页面。如果需要更多细节,请告诉我。

谢谢。

ajax请求的javascript发布代码:

var xhrRequests = [];
function filterByCancellation(){
    $( ".hotel_package_row:visible" ).each(function( index ) {
        var cancellation_obj = $(this).find( ".cancellationText" );
        var pack_price = 0;
        var hotel_price = 0;
        if ($(cancellation_obj).text()=="") {
            var hotelid = $(cancellation_obj).prev("a").data( "hotelid"),
                packid  = $(cancellation_obj).prev("a").data( "packid"),
                cancel  = $(cancellation_obj);
            if(!$('#anc-'+packid).is(':visible') && $('#inp-'+packid).val()=="0"){
                $('#inp-'+packid).val("1");
                cancel.html('').slideToggle(function(){
                    var data = { hotelid: hotelid, packid: packid };
                    pack_price = parseInt($('#packprice_'+packid).val());
                    var xhr = $.ajax({
                      type: "POST",
                      url: "location_penny.php?section=cancellationData",
                      data: data,
                      success: function(result) {
                        //cancel.html(result);
                        if(result.indexOf('<div style="display:none;">') > -1){
                            $(cancellation_obj).parents('.hotel_package_row').html('');
                        }else{
                            hotel_price = parseInt($('#'+hotelid).find('.currency-sign-before').html());
                            if($("#price_update_"+hotelid).val()=='0'){
                                //alert("hotel price "+hotel_price+" updating for the first time with package "+pack_price);
                                $('#'+hotelid).find('.currency-sign-before').html(pack_price);
                                $("#price_update_"+hotelid).val("1");
                            }
                            if(pack_price<=hotel_price){
                                //alert("hotel price "+hotel_price+" is greater than current package price "+pack_price);
                                $('#'+hotelid).find('.currency-sign-before').html(pack_price);
                            }
                            $('#img-'+packid).hide();
                            $('#anc-'+packid).show();
                        }
                      },
                      async:true
                    });
                    xhrRequests.push(xhr);
                });
            }
        }
    });
}
function cancelXhrRequests(){
    for (var i = 0; i < xhrRequests.length; i++) {
        xhrRequests[i].abort();
    }
}

这可能是由重定向的URL或类似的原因引起的。Apache有两个保存在/var/log文件夹中的日志文件(基于您的Linux发行版):

  • Debian基本发行版:/var/log/apache2/error_log/var/log/apache2/access_log
  • RedHat基本发行版:/var/log/httpd/error_log/var/log/httpd/access_log

因此,您可以在继续模式(即tail -f ADDRESS_OF_LOG_FILE)中使用tail命令来观察您的请求以及处理它们时发生的错误。