0

运行 phonegap 应用程序时出现该错误。我检查了我的代码多少次,但我看不到我的错误在哪里。在我使用 JSON.parse(response) 之后显示的错误但是当我删除它时,它可以正确执行。有人能帮我吗?谢谢

这是我的代码:

function onReconnect(position) {

    Lat = position.coords.latitude;
    Long = position.coords.longitude;
    d = new Date();
    date = d.getUTCDate();
    hour = d.getUTCHours() + 8;
    minutes = d.getUTCMinutes();
    secs = d.getUTCSeconds();
    year = d.getUTCFullYear();
    mon = d.getUTCMonth() + 1;
    day = d.getUTCDay();
    time = year + "-" + mon + "-" + date + " " + hour + ":" + minutes + ":" + secs;

    var sendData3 = {
        "name": stringValue2
    };


    $.post('http://192.168.254.110/webs/main/ajax/TimeTypeCheck.php', sendData3, function (data) {
        $("#info").html(data);
        var TCReturnMessage = data;
        var TCmess = TCReturnMessage.toString().trim();

        var sendData2 = {
            "name": VLmess,
            "Lat": Lat,
            "Long": Long,
            "time": time,
            "Timetype": TCmess
        };
        $.post('http://192.168.254.110/webs/main/ajax/Reconnect.php', sendData2, function (data) {
            $("#info").html(data);
            document.location.href = "TimeOnStatus.html";
        });
    });

}

function onError(error) {
    alert('code: ' + error.code + '\n' +
        'message: ' + error.message + '\n');
}

function onSuccess(position) {

    $("#Login").click(function (evt) {

        var currentPage = window.location.href;
        //store it
        window.sessionStorage.setItem("page", currentPage);
        //check if the previous page is the one you wanted.


        stringValue2 = window.localStorage.getItem("data");
        //stringValue2 = stringValue2.trim();
        username = $("#username").val();
        password = $("#password").val();
        d = new Date();
        date = d.getUTCDate();
        hour = d.getUTCHours() + 8;
        minutes = d.getUTCMinutes();
        secs = d.getUTCSeconds();
        year = d.getUTCFullYear();
        mon = d.getUTCMonth() + 1;
        day = d.getUTCDay();
        time = year + "-" + mon + "-" + date + " " + hour + ":" + minutes + ":" + secs;
        sendData = {
            "username": username,
            "password": password,
            "time": time
        };

        $.post('http://192.168.254.110/webs/main/ajax/validateLogin.php', sendData, function (data) {
            $("#info").html(data);
            var VLReturnMessage = data;
            VLmess = VLReturnMessage.toString().trim();

            if (VLmess != "" && VLmess != "Invalid Login!") {
                localStorage.setItem("message", VLReturnMessage);
                window.localStorage.setItem("username", username);
                window.localStorage.setItem("data", data);
                sendData1 = {
                    "name": VLmess
                };

                $.post('http://192.168.254.110/webs/main/ajax/StatusCheck.php', sendData1, function (response) {
                    $("#info").html(response);

                    var SCReturnMessage = JSON.parse(response);
                    if (SCReturnMessage.status == "yes") {
                        navigator.geolocation.getCurrentPosition(onReconnect, onError);

                    } else {
                        alert("hey!");
                        var sendData4 = {
                            "name": VLmess,
                            "time": time
                        };
                        $.post('http://192.168.254.110/webs/main/ajax/AccountStatus.php', sendData4, function (data) {
                            $("#info").html(data);
                        });
                        document.location.href = "trackme.html";

                    }

                });

            } else {}

        });


    });

}


function onError() {
    alert("Error");
}
4

0 回答 0