1

运行包含表单的 html 文件时出现此错误。它应该在登录后移动到另一个屏幕。

GET http://mdsad.com/p.js?v=1373144857354 

我不明白我在代码中哪里出错了。它甚至没有进入被调用的函数。

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://static.stackmob.com/js/stackmob-js-0.9.1-bundled-min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Pocket Docket</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function nextpage() {
    alert("function");
    StackMob.init({
        publicKey: "my_key",
        apiVersion: 0
    });
    var u = document.getElementById('username').value;
    var p = document.getElementById('password').value;
    alert(u);
    alert(p);
    var user = new StackMob.User({
        username: u,
        password: p
    });
    user.login(false, {
        success: function(model, result, options) {
            alert("Success");
            alert("Success");
            window.open('newp1.html');
            StackMob.isUserLoggedIn(u, {
                yes: function() {
                    alert("Logged In!");
                },
                no: function() {
                    alert("Login Error!");
                }
            });
        },
        error: function(model, result, options) {
            console.log(result);
            alert("Login Error!");
        }
    });
};
</script>
</head>
<body>
<div id="topPan">
    <div id="topHeaderPan"></div>
    <div id="toprightPan"></div>
</div>
<div id="bodyPan">
    <div id="bodyleftPan">
        <h2>Pocket Docket</h2>

        <p class="greentext">For Every Salesman</p>

        <p>Pocket Docket is a means to simplify the working of the sales
        department in a company.</p>

        <p>For every salesperson, it is like a manager, assigning tasks and
        recording progress, updating it on their profiles. Easier to manage,
        higher the productivity.</p>
    </div>
    <div id="bodyrightPan">
        <div id="loginPan">
            <h2>Pocket Docket <span>login</span></h2>

            <form action="" method="post">
                <label>Login ID</label><input id="email" name="email" type=
                "text"> <label>Password</label><input id="pass" name="pass"
                type="password"> <input class="button" name="Input" onclick=
                "nextpage()" type="submit" value="Login">
            </form>
            <ul>
                <li class="nonregister">Forgot Password &nbsp;?</li>

                <li class="register">
                    <a href="#">Click Here</a>
                </li>
            </ul>
        </div>
        <div id="loginBottomPan">
            &nbsp;
        </div>
    </div>
</div>
</body>
</html>

错误出现在 download.js 中(我在浏览器控制台中不知道的一些文件)。请告诉我错误在哪里。

4

1 回答 1

0

我弄清楚你的代码有什么问题:

var u = document.getElementById('username').value;
var p = document.getElementById('password').value;

您的输入 ID 是“电子邮件”和“通过”,因此将上述行更改为:

var u = document.getElementById('email').value;
var p = document.getElementById('pass').value;

最好关闭“输入”标记希望它现在可以工作。

于 2013-07-09T08:07:57.177 回答