Javascript 为什么这在Internet Explorer上不起作用?[jQuery、收音机、选择器]

Javascript 为什么这在Internet Explorer上不起作用?[jQuery、收音机、选择器],javascript,jquery,internet-explorer,jquery-selectors,Javascript,Jquery,Internet Explorer,Jquery Selectors,我正在尝试调试在任何版本的Internet Explorer上都不起作用的东西 代码如下: <div id="sondage"> <input type="radio" name="reponse" value="oui" id="oui"> <label for="oui">Oui</label> <input type="radio" name="reponse" value="non" id="non">

我正在尝试调试在任何版本的Internet Explorer上都不起作用的东西

代码如下:

<div id="sondage">
    <input type="radio" name="reponse" value="oui" id="oui">
    <label for="oui">Oui</label>

    <input type="radio" name="reponse" value="non" id="non">
    <label for="non">Non</label>
</div>

<script type="text/javascript" charset="utf-8">
$(function(){

    $('#oui, #non').click(function(){
        reponse = $('input[name=reponse]:checked').val();
        sondage_id = <?php echo $sondage->id ?>;

        $.ajax({
            type: "GET",
            url: "<?php echo url_for('@sondage_repondre') ?>",
            data: "reponse="+reponse+"&id="+sondage_id,
            success: function(msg){
                resultat = msg.split('|');

                if (resultat[0] == "true") {
                    $('#sondage_message').html("<?php echo __('Merci.') ?>");
                } else {
                    $('#sondage_message').html("<?php echo __('Désolé, vous avez déjà voté pour ce sondage. Merci.') ?>");
                }
                $('#sondage').html(resultat[1]);
            }
        });

    });

});
</script>
以下是完整的输出:

再次感谢

您缺少一个var,它应该是:

var reponse = $('input[name=reponse]:checked').val();

其他变量也是如此……始终使用var来声明它们,无论它们位于何处,都不要依赖于不总是允许的隐式全局定义。

您确定这是导致错误的原因吗?我不相信IE的行号,但你可以通过硬编码那个值来验证,看看它是否有效。你有什么错误?请用呈现的代码视图源代码而不是实际源代码更新您的问题,好吗?你完全正确,我更新了这个问题。谢谢:您从IE得到的错误消息是什么?第511行,Char 7,Object不支持此属性或方法。但是隐式声明变量是完全有效的。这不应该导致脚本失败。当然,更好的编码实践是显式声明变量。@Metagrapher-这是无效的,在某些情况下是允许的。在这两种情况下,这都是不好的做法。@Pointy:我不知道!但看起来你是对的,完全正确,该死的,我几乎永远不会忘记那些东西。。。我的错。谢谢
var reponse = $('input[name=reponse]:checked').val();