页面在哪里花费时间

时间:2015-12-13 10:05:28

标签: php jquery html ajax curl

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

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

如果我尝试点击链接后收到第一个可用性,那么在点击后页面花费大约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();
    }
}

1 个答案:

答案 0 :(得分:0)

这可能是由重定向的网址或类似内容引起的。 Apache在/var/log文件夹上保存了两个日志文件(基于您的Linux发行版):

  • Debian base distr。:/var/log/apache2/error_log/var/log/apache2/access_log
  • RedHat base distr:/var/log/httpd/error_log/var/log/httpd/access_log

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

相关问题