dtsjq28482 2014-02-04 12:08
浏览 255
已采纳

小心:显示临时标题[重复]

This question already has an answer here:

I cant debug this message which appeared like a week ago.

I tried restoring to old files but this is odd, nothing solves my problem.

So: I have two long polling requests. (turning one of them off does not help).

for example this is one of them:

public function update_private_messages_ajax_handler(){
    global $wpdb;
    global $bp;
    $chat_table = $wpdb->prefix . 'bp_dollars_chat';

    $current_user = $bp->loggedin_user->id;

    ob_start();
    header("Content-Type: application/json");
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

    $startTime = time();
    while((time()-$startTime)<=20) {
        $messages = $wpdb->get_results(
            $wpdb->prepare("(SELECT * 
                FROM $chat_table 
                WHERE to_user = %d
                AND recd = 1
                AND id > %d
                ORDER BY id DESC) ORDER BY id ASC
            ", $current_user, $_POST['last_id'])
        );
        if($messages) {
            foreach($messages as $v){
                //$v->timestring = date_i18n($this->date_format.' - '.$this->time_format, $v->unix_timestamp+$this->gmt_offset);
                $v->name = get_dollar_name($v->from_user);
                $v->avatar = get_avatar($v->from_user, 50);
                //$v->message = convert_smilies( $v->message );
            }
            $response = json_encode(array('no_participation' => $this->no_participation, 'success'=> 1, 'messages'=>$messages));

            echo $response;
            ob_flush(); flush();
            exit;
        } else {
            sleep($this->options['timeout_refresh_messages']);
        }
    }

    $response = json_encode(array('no_participation' => $this->no_participation, 'success'=> 0));

    echo $response;
    ob_flush(); flush();
    exit;
}

As you can see, I sent cache-control headers, so this should not be problem described here I also dont have any adBlocker installed and this is local installation.

there is a client-side script

update_private_messages: function() {
    jQuery.post(quick_chat.ajaxurl, {
            action: 'quick-chat-ajax-update-pmessages',
            last_id: quick_chat.last_private_id
        },
        function(data) {
            console.log(data);
            if(data.success == 1) {
                var updates = data.messages;
                var already_notified = 0;
                var chat_history = jQuery('.popoverx.chat.in .chathistory');
                for(var i=0;typeof(updates[i])!='undefined';i++){
                    // this in case if window open and new message is for current user
                    if(quick_chat.privateOpen == true && (quick_chat.privateOhter == updates[i].from_user || quick_chat.privateOhter == updates[i].to_user )) {
                        // @TODO do I animate every time?
                        jQuery(chat_history).prepend(quick_chat.single_private_html(updates[i])).animate({scrollTop: 0}, 500);
                    } else if(updates[i].recd == 1 && updates[i].from_user != quick_chat.user_id) {
                        // not yet in unread group
                        if(quick_chat.privateUnread.indexOf(parseInt(updates[i].from_user)) == -1) {
                            quick_chat.privateUnread.push(parseInt(updates[i].from_user));
                        }
                        if(already_notified == 0 && quick_chat.last_private_id != 0 && updates[i].from_user != quick_chat.user_id) {
                            if(quick_chat.play_audio == 1) {
                                quick_chat.audio_element.play();
                            }
                            already_notified = 1;
                        }
                    }
                }
                // update label
                var unreadIcon = jQuery('#bs-navbar-right > li > a.messages');
                if(quick_chat.privateUnread.length != 0) {
                    unreadIcon.find('span').remove().end().append('<span class="label label-danger">'+ quick_chat.privateUnread.length +'</span>')
                } else {
                    unreadIcon.find('span').remove()
                }
                quick_chat.last_private_id = updates[updates.length-1].id;
            }
            quick_chat.update_private_messages();
        }, 'json'
    );
}

Is this normal? I cant be normal message for long polling - since its a pending request. Its just does not seem to be documented anywhere


Note: also I have many short-polling requests and this could be case where more then 6 requests cancel each other but - I also tried turning all other requests off, except one (long polling) and this is not a case


Here is a original script working so you can see the message: http://www.techytalk.info/wordpress/quick-chat/


Just to summirize this question: Is this normal? (I don't see this problem on other sites where comet is used) - and if not - Where should I seek for problem, clientside or server-side? Here they say that in such case request is not sent at all, but thats not true, my scripts are working and I cant chat (this is a chat script)

</div>
  • 写回答

4条回答 默认 最新

  • doumanshan6314 2014-02-16 17:45
    关注

    This is completely normal in chrome (as of recently). There was a discussion here where they discuss the change, essentially on pending requests it was showing certain headers incorrectly, so now they show a warning that these are provisional headers.

    From the discussion:

    Network Panel: add caution about provisional request headers. (was: In developer tools, request headers for pending requests are incorrect)

    I don't know when the fix actually got released, or if you leave Chrome open all the time and so it didn't update for a while - but almost certainly it is nothing you did - just how Chrome works now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)