我有3个页面:page1.php page2.php page3.php page1.php具有ajax,正在调用page2.php。 page2.php具有php和javascript代码,如果一切正确,则ajax调用page3.php,将所有内容注册在mysql中。
只有一个问题。我认为ajax调用子页面,该子页面不能调用另一个子页面,对吗?
每个单独的页面都有奇迹。 但是page2.php不能被ajax调用。
page1.php
<script>
var x = document.getElementById("demo");
function getLocation6() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition6, showError);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition6(position) {
var latfinal=position.coords.latitude;
var longfinal=position.coords.longitude;
var latlng = new google.maps.LatLng(latfinal, longfinal);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
var Var_JavaScript = results[1].formatted_address;
$.ajax({
type: "POST",
url: "insert-fichaje2.php?lat="+latfinal+"&long="+longfinal+"&status=ReanudarTransporte&usuario=<?php echo htmlspecialchars($_SESSION["username"]); ?>&direccion="+Var_JavaScript +"&empresa=<?php echo $empresa;?>",
dataType: "json",
success: function() {
$.ajax({
type: "POST",
url: "page2.php?lat="+latfinal+"&long="+longfinal+"&status=ReanudarTransporte&usuario=<?php echo htmlspecialchars($_SESSION["username"]); ?>&direccion="+Var_JavaScript +"&empresa=<?php echo $empresa;?>",
dataType: "json",
});
alert("Cambio con exito!");
location.reload();
},
error: function() {
alert(" ERROR!!!");
location.reload();
}
});
}
}
});
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude + "";
}
function showError(error) {
switch(error.code) {
case error.PERMISSION_DENIED:
alert("Has detenido acceso a tu ubicacion. Porfavor dame permiso a tu ubicacion!");
x.innerHTML = "Has detenido acceso a tu ubicacion. Porfavor dame permiso a tu ubicacion."
break;
case error.POSITION_UNAVAILABLE:
x.innerHTML = "No tengo tu ubicacion"
break;
case error.TIMEOUT:
x.innerHTML = "The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
x.innerHTML = "A aparesido un error."
break;
}
}
</script>
page2.php目的是为了使los circulos许可在circulos上的合法使用,并且不会在任何raditro del circulo上作介绍。
<script>
window.onload = function init() {
var monitorzonafichaje = "<?php echo $avisosficahejzonas;?>";
var monitorzonanave = "<?php echo $fichajefueranave;?>";
var monitorzonapunctos = "<?php echo $fichajefuerapunctos;?>";
var latempresa= "<?php echo $latempresa;?>";
var longempresa= "<?php echo $longempresa;?>";
var latuser ="<?php echo $lat;?>";
var longuser = "<?php echo $long;?>";
if (monitorzonafichaje === "1"){
if (monitorzonanave === "1"){
var
contentCenter = '<span class="infowin">Center Marker (draggable)</span>',
contentCenter2 = '<span class="infowin">Center2 Marker (draggable)</span>',
contentA = '<span class="infowin">Marker A (draggable)</span>',
contentB = '<span class="infowin">Marker B (draggable)</span>';
var
latLngCenter = new google.maps.LatLng(latempresa, longempresa),
latLngCMarker = new google.maps.LatLng(latempresa, longempresa),
latLngCMarker2 = new google.maps.LatLng(38.0814, -93.5105),
latLngA = new google.maps.LatLng(latuser, longuser),
latLngB = new google.maps.LatLng(38, -93),
map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: latLngCenter,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
}),
markerCenter = new google.maps.Marker({
position: latLngCMarker,
title: 'Location',
map: map,
draggable: true
}),
markerCenter2 = new google.maps.Marker({
position: latLngCMarker2,
title: 'Location',
map: map,
draggable: true
}),
infoCenter = new google.maps.InfoWindow({
content: contentCenter
}),
markerA = new google.maps.Marker({
position: latLngA,
title: 'Location',
map: map,
draggable: true
}),
infoA = new google.maps.InfoWindow({
content: contentA
}),
markerB = new google.maps.Marker({
position: latLngB,
title: 'Location',
map: map,
draggable: true
}),
infoB = new google.maps.InfoWindow({
content: contentB
})
// exemplary setup:
// Assumes that your map is signed to the var "map"
// Also assumes that your marker is named "marker"
,
circle = new google.maps.Circle({
map: map,
clickable: false,
// metres
radius: 100,
fillColor: '#fff',
fillOpacity: .6,
strokeColor: '#313131',
strokeOpacity: .4,
strokeWeight: .8
});
circle2 = new google.maps.Circle({
map: map,
clickable: false,
// metres
radius: 100000,
fillColor: '#fff',
fillOpacity: .6,
strokeColor: '#313131',
strokeOpacity: .4,
strokeWeight: .8
});
// attach circle to marker
circle.bindTo('center', markerCenter, 'position');
circle2.bindTo('center', markerCenter2, 'position');
var
// get the Bounds of the circle
bounds = circle.getBounds()
bounds2 = circle2.getBounds()
// Note spans
,
noteA = jQuery('.bool#a'),
noteB = jQuery('.bool#b');
var myvar = bounds.contains(latLngA);
if (!myvar){
$.ajax({
type: "POST",
url: "page3.php?dentro=no",
dataType: "json",
});
}else{
$.ajax({
type: "POST",
url: "page3.php?dentro=yes",
dataType: "json",
});
}
//--------
}else{
if (monitorzonapunctos === "1"){
}
}
}
};
</script>
和page3.php是php插入mysql。