Este es mi codigo, sigo sin poder encontrar el problema, en distintos exploradores me bota un error distinto:
En Google Chrome: SyntaxError: Unexpected token <
En Windows Internet Explorer 9: SyntaxError: Syntax error
En Mozila Firefox: SyntaxError: invalid regular expression flag b
ver.php:
Código Javascript
:
Ver original<?php
mysql_connect('localhost','usuario','contraseña');
mysql_select_db('rutas');
$query = mysql_query("SELECT * FROM mapdir");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ver Ruta</title>
</head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="js/jquery-1.4.3.min.js"></script>
<style type="text/css">
#address{
float:left;
width:300px;
margin-left:10px;
border:2px dashed #F5F5F5;
padding:0 20px 20px 20px
}
#address ul{
padding:0;
list-style:none
}
#address ul li{
height: auto;
width: 300px;
-moz-border-radius: 4px;
border-radius: 4px;
background:#F9F9F9;
padding:6px
}
#address ul li a{
padding:0;
font:normal 11px Verdana, Geneva, sans-serif;
color:#03C
}
h2{
font:normal 16px Tahoma, Geneva, sans-serif;
color:#900
}
</style>
<body onLoad="goma()">
<div id="mappy" style="width:800px; height:550px; float:left"></div>
<div id="address">
<h2>Rutas Generadas</h2>
<ul>
<?php
while($row = mysql_fetch_array($query)){
?>
<li><a href="ver.php?id=<?php echo $row['id']?>"><?php echo $row['origen']." - ".$row['destino'] ?> </a></li>
<?php
}
?>
</ul>
</div>
<script>
var map, ren, ser;
var data = {};
function goma()
{
map = new google.maps.Map( document.getElementById('mappy'), {'zoom':12, 'mapTypeId': google.maps.MapTypeId.ROADMAP, 'center': new google.maps.LatLng(-12.1008684,-77.0288967) })
ren = new google.maps.DirectionsRenderer( {'draggable':true} );
ren.setMap(map);
ser = new google.maps.DirectionsService();
fetchdata()
}
function setroute(os)
{
var wp = [];
for(var i=0;i<os.waypoints.length;i++)
wp[i] = {'location': new google.maps.LatLng(os.waypoints[i][0], os.waypoints[i][1]),'stopover':false }
ser.route({'origin':new google.maps.LatLng(os.start.lat,os.start.lng),
'destination':new google.maps.LatLng(os.end.lat,os.end.lng),
'waypoints': wp,
'travelMode': google.maps.DirectionsTravelMode.DRIVING},function(res,sts) {
if(sts=='OK')ren.setDirections(res);
})
}
function fetchdata()
{
$.post("process.php",{command:'fetch', id:'<?php echo $_GET['id'] ?>'},function(data){
try { setroute( eval('(' + data + ')') ); }
catch(e){ alert(e); }
});
}
</script>
</body>
</html>
process.php
Código PHP:
<?php
ob_start(); header('Cache-Control: no-store, no-cache, must-revalidate');
$data = $_REQUEST['mapdata'];
mysql_connect('localhost','usuario','contraseña');
mysql_select_db('rutas');
if($_REQUEST['command']=='save')
{
$query = "INSERT INTO mapdir VALUES('','".$_POST['origen']."','".$_POST['destino']."','".$data."')";
if(mysql_query($query)) echo "bien-".mysql_insert_id();
die(mysql_error());
}
if($_REQUEST['command']=='fetch')
{
$query = "SELECT value FROM mapdir WHERE id = '".$_POST['id']."'";
if(!($res = mysql_query($query)))die(mysql_error());
$rs = mysql_fetch_array($res,1);
die($rs['value']);
}
?>
Continua...