为什么这在 Internet Explorer 上不起作用? [jQuery、单选、选择器]
我正在尝试调试在任何版本的 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>
错误发生在该行 (reponse = $('input[name=reponse]:checked').val();
)。
你知道发生了什么吗?
谢谢!
编辑:按照要求:错误是:
Line 511, Char 7, Object doesn't support this property or method.
这是完整的输出: http://pastie.org/1355610
谢谢再次!
I'm trying to debug something that does not work on any version of Internet Explorer.
Here's the code :
<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>
The error happens on that line (reponse = $('input[name=reponse]:checked').val();
).
Do you have any idea of what's happening?
Thanks!
EDIT: As asked: the error is:
Line 511, Char 7, Object doesn't support this property or method.
And here's the complete output : http://pastie.org/1355610
Thanks again!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在那里缺少一个
var
,它应该是:其他变量也是如此...始终使用
var
来声明它们,无论它们在哪里,不要依赖于并不总是允许的隐式全局定义。You're missing a
var
in there, it should be:The same goes for your other variables...always use
var
to declare them, no matter where they are, don't depend on a implicit global definition which isn't always allowed.