Javascript TypeError:这在ajax调用和google应用程序映射中未定义
我有一个asp mvc项目,其中要求用户通过google maps API进行地理定位,因此我不得不使用jquery 1.7.2并保存其坐标,但当我尝试通过ajax请求保存坐标时,我在firebug上遇到此错误,并停止了所有其他代码 正如您所看到的,错误的描述非常简单,下面是jquery上的函数,它调用了这个函数Javascript TypeError:这在ajax调用和google应用程序映射中未定义,javascript,jquery,ajax,google-maps,Javascript,Jquery,Ajax,Google Maps,我有一个asp mvc项目,其中要求用户通过google maps API进行地理定位,因此我不得不使用jquery 1.7.2并保存其坐标,但当我尝试通过ajax请求保存坐标时,我在firebug上遇到此错误,并停止了所有其他代码 正如您所看到的,错误的描述非常简单,下面是jquery上的函数,它调用了这个函数 function ReviewAtEnd() { if (typeof (idserialF) != "undefined" && idserialF
function ReviewAtEnd() {
if (typeof (idserialF) != "undefined" && idserialF != null) {
var datax = { idjob: idjobx, latitud: Latitud, longitud: Longitud, coordinates: coordenadasGM };
var urlx = "/JOBS/PROG41/FailedItemOnSite";
$.ajax({
type: "POST",
url: urlx,
data: datax,
async: false,
success: function (data) {
mostrar_alert_ui(data.titulo, data.mensaje, 350);
if (data.success) {
AfterPassedTest();
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Failed " + urlx);
alert(xhr.responseText);
alert(thrownError);
}
});
}
}
更新
这是我错过的谷歌地图功能
var Latitud;
var Longitud;
var coordenadasGM;
function showMap() {
//If HTML5 Geolocation Is Supported In This Browser
if (navigator.geolocation) {
//Use HTML5 Geolocation API To Get Current Position
navigator.geolocation.getCurrentPosition(function (position) {
//Get Latitude From Geolocation API
var latitude = position.coords.latitude;
Latitud = latitude;
//Get Longitude From Geolocation API
var longitude = position.coords.longitude;
Longitud = Longitud;
//Define New Google Map With Lat / Lon
var coords = new google.maps.LatLng(latitude, longitude);
coordenadasGM = coords;
//Specify Google Map Options
var mapOptions = {
zoom: 15,
center: coords,
mapTypeControl: true,
navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL }, mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("mapContainer"), mapOptions);
var marker = new google.maps.Marker({
position: coords,
map: map,
title: "You Are Here!"
});
}
);
} else {
//Otherwise - Gracefully Fall Back If Not Supported... Probably Best Not To Use A JS Alert Though :)
mostrar_alert_ui("WARNING", "Geolocation API is not supported in your browser.", 350)
}
}
//Once Page Is Populated - Initiate jQuery
$(document).ready(function () {
//Show The Map
showMap();
// When The Viewing Window Is Resized
$(window).resize(function () {
//CSS Resizes Container So Lets Recall The Map Function
showMap();
});
});
Jsfiddle here->错误显然来自maps API触发错误的部分看起来像LatLng的toString方法,但是您的代码都与maps API无关,无法根据给定的代码给出答案。但是,此错误毫无意义。试着在chrome中运行它,也许你会遇到另一个错误firebug中经常有错误的错误报告,特别是当jquery是loaded@Dr.Molle刚刚向通用汽车公司更新了问题function@Dr.Molle添加了jsfiddle,thanks@Dr.MolleChrome错误->