English 中文(简体)
Ajax don t在网基浏览器上触发变化
原标题:Ajax doesn t trigger a change-event on a webkit based browser

我已改编了一个焦土,以满足我向服务器发出全球教育要求的需要,作为“选择”这些要求的一种方式。

我也增加了一些javascript代码,以添加一些关键特征,例如:根据吉克里花gin变化的时期价值的变化,它相应改变了Icon。

为了让它基本上发挥作用,我作出这样的决定,即当阿贾克斯获得“完整”活动时,它就把“头盔”活动拖到时间段,从而启动 j验证功能,以改变身份标志。

这里是我稍作修改的“ j子”守则:

/**
 * ping for jQuery
 * 
 * Adapted by Carroarmato0  (to actually work instead of randomly "pinging" nowhere instead of faking
 *
 * @auth Jessica
 * @link http://www.skiyo.cn/demo/jquery.ping/
 *
 */
(function($) {
    $.fn.ping = function(options) {
        var opts = $.extend({}, $.fn.ping.defaults, options);
        return this.each(function() {
            var ping, requestTime, responseTime ;
            var target = $(this);
                        var server = target.html();
                        target.html( <img src="img/loading.gif" alt="loading" /> );
            function ping() {
                $.ajax({url:  http://  + server,
                    type:  GET ,
                    dataType:  html ,
                    timeout: 30000,
                    beforeSend : function() {
                        requestTime = new Date().getTime();
                    },
                    complete : function() {
                        responseTime = new Date().getTime();
                        ping = Math.abs(requestTime - responseTime);

                                                if (ping > 2000) {
                                                    target.text( niet bereikbaar );
                                                } else {
                                                    target.text(ping + opts.unit);
                                                }

                                                target.change();
                    }
                });
            }
            ping();
            opts.interval != 0 && setInterval(ping,opts.interval * 1000);
        });
    };
    $.fn.ping.defaults = {
        interval: 3,
        unit:  ms 
    };
})(jQuery);

具体目标:变化;即触发“变化”活动的代码:

echo "  <td class="center"><span id="ping$pingNb" onChange="checkServerIcon(this)" >" .$server[ IP ] . "</span></td>";

在L.R.A.工程中,检查ServerIcon(这部工程)被执行,并穿过该功能。

function checkServerIcon(object) {
    var delayText = object.innerHTML;
    var delay = delayText.substring(0, delayText.length - 2);

    if ( isInteger(delay) ) {
        object.parentNode.previousSibling.parentNode.getElementsByTagName( img )[0].src =  img/servers/enable_server.png ;

    } else {

        if (delay == "bezig.") {
            object.parentNode.previousSibling.parentNode.getElementsByTagName( img )[0].src =  img/servers/search_server.png ;
        } else {
            object.parentNode.previousSibling.parentNode.getElementsByTagName( img )[0].src =  img/servers/desable_server.png ;
        }
    }

}
问题回答

我猜测,你可以尝试使用 j子的内装检查仪:

$(object).parent().prev().parent().find( img:first ).attr({src:  image-source-here });

浏览器之间可能有一些固定的电梯,而是使用 j鱼方法。

Use the JQuery change method instaid of javascript s onchange the target.change() will only trigger jquery s bounded functions

解决办法:

我将换面活动从我的时代删除,而是给它一个类别的名称:

echo "  <td class="center"><span class="ping" id="ping$pingNb">" .$server[ IP ] . "</span></td>";

其次,我做了“ j子”补充了变革活动本身:

<script type="text/javascript">
    $(document).ready(function(){
        $("span.ping").change(checkServerIcon);
    });
</script>

我的javascript功能必须改写:

function checkServerIcon() {
    var tr = $(this).parent().parent();
    var img = tr.find( td>img ).first().attr( src );
    var delayText = tr.find( td>span ).text();
    var delay = delayText.substring(0, delayText.length - 2);

    if ( isInteger(delay) ) {
        tr.find( td>img ).first().attr( src , img/servers/enable_server.png );

    } else {

        if (delay == "bezig.") {
           tr.find( td>img ).first().attr( src , img/servers/search_server.png );
        } else {
            tr.find( td>img ).first().attr( src , img/servers/desable_server.png );
        }
    }   
}

如今,该守则在Emth和Webkit式浏览器(如谷歌 Chrome)中发挥作用。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签