.js 파일에서 아래의 자바 스크립트를 실행하는 중 다음 오류가 발생합니다.변수가 정의되지 않았습니다. 이상한 변수 범위
Uncaught ReferenceError: startloc is not defined
는하지만 내가 그들 아래에있는 모든 방법을 볼 수있는 스크립트의 상단에있는 변수를 선언하면 그것이 정의되지 않은 말한다 왜 .. 난 모르겠어 ... 생각
var startLoc = new Array();
var endLoc = new Array();
//Map Initialisation
function initMap() {
}
//Marker addon
function addMarker(lattitude, longitude) {
}
// Sets the map on all markers in the array.
function setMapOnAll(map) {
}
//Clear markers on the map
function clearMarkers() {
}
//delete markers array
function deleteMarkers() {
}
//Plot the markers on the map
$("document").ready(function(){
$("#getData").submit(function(event){
event.preventDefault();
var reset = 0;
window.setInterval(function(){
$.ajax({
url : "/getVehiclePosition.php",
type: "POST",
datatype: "json",
data: "",
success: function(data, textStatus, jqXHR)
{
var json_obj = $.parseJSON(data);//parse JSON
deleteMarkers();
for (var i in json_obj)
{
if (reset = 0){
startloc[i-1] = "X";
reset = 1;
} else {
endLoc[i-1] = "Y";
reset = 0;
}
console.log(startloc[i-1]);
console.log(endloc[i-1]);
}
},
error: function (jqXHR, textStatus, errorThrown)
{
console.error(
"The following error occurred: "+
textStatus, errorThrown
);
}
});
}, 15000);
});
});
JavaScript 식별자는 대소 문자를 구분합니다 – Musa