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");
}