$ .post在Firefox中不起作用 [英] $.post not working in firefox

查看:129
本文介绍了$ .post在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,它可以在IE和Chrome中正常运行,但不能在FF中运行

Here's my code it works fine in IE and Chrome, but not in FF

<script type="text/javascript">
    function get() {
        $.post(
            'regAuth.php', 
            {usrName: login.usrName.value, password: login.password.value},
            function (output) {
                $('#error').html(output).show();
            }
        );
    }
</script>

推荐答案

您必须正确获取输入元素:

You have to get the input elements properly:

{ usrName: $("input[name='usrName']").val(), password: $("input[name='password']").val() }

当你有这样的事情时:

login.usrName.value

某些浏览器会去寻找名为login的顶级元素(窗体,框架等),但您一定不要依赖这种东西.

Some browsers will go and look for top level element named login (form, frame etc) but you must not depend on such thing.

由于我认为您已经在使用jQuery最佳实践,因此也要使用它来读取输入值.

As you're already using jQuery best practice in my opinion is to use it to read the input values as well.

这篇关于$ .post在Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆