gpt4 book ai didi

php - 这个javascript和php代码有什么问题

转载 作者:行者123 更新时间:2023-11-30 09:05:03 25 4
gpt4 key购买 nike

我已经尝试调试了一个小时:

<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.";";
for ($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()">

我得到的错误是:

Uncaught SyntaxError: Unexpected token <

Uncaught ReferenceError: initialize is not defined

当我删除那个 PHP 代码块时,它不会给我那个错误。为什么?

更新:

这里是错误的地方:

$(".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 is line 76
});
});

这是从该初始化函数生成的 JS:

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]});
}

最佳答案

嗯,<br />没有 javascript,因此会导致错误。

其余的 html 在 javascript block 中回显...

如您所见,它基本上是一条来自 php 的大错误消息。

关于php - 这个javascript和php代码有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5838008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com