What is wrong with this javascript and php code -
i've been trying debug hour:
<script type="text/javascript"> function initialize() { alert('test'); var latlngarr = new array(); var titlearr = new array(); <?php echo "latlngarr.length=".$response->total.";"; echo "titlearr.length=".$response->total.";"; ($i=0;$i<$response->total;$i++){ echo "latlngarr[".$i."] = new google.maps.latlng(".$response->businesses[$i]->location->coordinate->latitude.",".$response->businesses[$i]->location->coordinate->longitude.");"; echo "titlearr[".$i."] = \"".$response->businesses[$i]->name."\";"; } ?> var myoptions = { zoom: 10, center: latlngarr[0], maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); var markerarr = new array(titlearr.length); for(var i=0;i<markerarr.length;i++) markerarr[i] = new google.maps.marker({position: latlngarr[i], map: map, title:titlearr[i]}); } </script> <body onload="initialize()">
the error got is:
uncaught syntaxerror: unexpected token <
and
uncaught referenceerror: initialize not defined
when remove block of php
code, doesn't give me error. why?
update:
here's error is:
$(".saved").live('click', function() { var $btn = $(this); $.post("update.php", {uid: my_uid, save: "no", mid: "<?php echo $mid; ?>"}, function(){ settimeout(function(){ $btn.replacewith('<a class="save action_btn" onclick="return false;">save</a>'); }, 100); //this line 76 }); });
here's generated js initialize function:
function initialize() { alert('test'); var latlngarr = new array(); var titlearr = new array(); <br /> <font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> notice: undefined property: stdclass::$total in c:\wamp\www\movie.php on line <i>89</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>call stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>time</th><th align='left' bgcolor='#eeeeec'>memory</th><th align='left' bgcolor='#eeeeec'>function</th><th align='left' bgcolor='#eeeeec'>location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>711160</td><td bgcolor='#eeeeec'>{main}( )</td><td title='c:\wamp\www\movie.php' bgcolor='#eeeeec'>..\movie.php<b>:</b>0</td></tr> </table></font> latlngarr.length=;<br /> <font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> notice: undefined property: stdclass::$total in c:\wamp\www\movie.php on line <i>90</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>call stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>time</th><th align='left' bgcolor='#eeeeec'>memory</th><th align='left' bgcolor='#eeeeec'>function</th><th align='left' bgcolor='#eeeeec'>location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>711160</td><td bgcolor='#eeeeec'>{main}( )</td><td title='c:\wamp\www\movie.php' bgcolor='#eeeeec'>..\movie.php<b>:</b>0</td></tr> </table></font> titlearr.length=;<br /> <font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> notice: undefined property: stdclass::$total in c:\wamp\www\movie.php on line <i>91</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>call stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>time</th><th align='left' bgcolor='#eeeeec'>memory</th><th align='left' bgcolor='#eeeeec'>function</th><th align='left' bgcolor='#eeeeec'>location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>711160</td><td bgcolor='#eeeeec'>{main}( )</td><td title='c:\wamp\www\movie.php' bgcolor='#eeeeec'>..\movie.php<b>:</b>0</td></tr> </table></font> var myoptions = { zoom: 10, center: latlngarr[0], maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); var markerarr = new array(titlearr.length); for(var i=0;i<markerarr.length;i++) markerarr[i] = new google.maps.marker({position: latlngarr[i], map: map, title:titlearr[i]}); }
well, <br />
no javascript cause error.
as rest of html echoed inside javascript block...
as can see it´s 1 big error message, coming php.
Comments
Post a Comment