몇 가지 유사한 스레드를 살펴 보았지만 잘못된 부분을 정확히 볼 수 없습니다. AJAX & PHP를 사용하여 작성중인 앱에 & 명의 사용자를 저장하고 있습니다. 나는 AJAX & PHP가 내 데이터베이스 테이블에 모든 것을 저장하기 때문에 (심지어 거짓 더미 & lng 값) 저장된다는 것을 알고있다. 저는 몇 시간 동안 변수를 가지고 놀았으며 지금까지 가지고있는 최선의 결과는 데이터베이스에 '0'값이 삽입 된 것입니다. 는 AJAX 기능에 위도 & LNG의 값을 전달하지 왜 사람이 볼 수있는 경우AJAX를 사용하여 PHP에 Geolocation 데이터 게시
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
getCurrentLocation();
}
function onError(message) {
navigator.notification.alert(message, "", "Error");
}
function getCurrentLocation() {
navigator.geolocation.getCurrentPosition(locationSuccess, onError);
}
function locationSuccess(position) {
lat = document.getElementById("latSpan");
lon = document.getElementById("latSpan");
latitude = position.coords.latitude;
longitude = position.coords.longitude;
}
//recording function
function getXMLObject() //XML OBJECT
{
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") // For Old Microsoft Browsers
}
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") // For Microsoft IE 6.0+
}
catch (e2) {
xmlHttp = false // No Browser accepts the XMLHTTP Object then false
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
{
xmlHttp = new XMLHttpRequest(); //For Mozilla, Opera Browsers
}
return xmlHttp; // Mandatory Statement returning the ajax object created
}
var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object
function ajaxFunction() {
var getdate = new Date(); //Used to prevent caching during ajax call
if(xmlhttp) {
xmlhttp.open("POST","http://www.lauracrane.co.uk/app/rec/location.php",true); //
xmlhttp.onreadystatechange = handleServerResponse;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send("latitude=" + latitude + "&longitude=" + longitude);
}
}
function handleServerResponse() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200) {
document.getElementById("message").innerHTML=xmlhttp.responseText;
}
else {
alert("Error during AJAX call. Please try again");
}
}}'
궁금 해서요.
도움을 주시면 감사하겠습니다. :)
로라
을 사용하는 것이 좋습니다까요? 왜냐하면 그건 괜찮아 보일테니까. 위도와 경도를 저장하기 위해 INT를 사용하는 경우 문제가 데이터베이스 측에있을 수 있습니다. – cleanunicorn
안녕하세요, VARCHAR입니다. - 그냥 확인했지만 도움을 주셔서 감사합니다. :) – LCrane86