Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SyntaxError:属性列表javascript后缺少}_Javascript_Php_Google Maps - Fatal编程技术网

SyntaxError:属性列表javascript后缺少}

SyntaxError:属性列表javascript后缺少},javascript,php,google-maps,Javascript,Php,Google Maps,我得到下面的错误 错误 SyntaxError:属性列表后缺少} 内容:Al futaim,贸易公司Saih Shuaib 3号36号M楼 - PHP代码 $content=$servicecenter->getCompanyName()."<br />".$servicecenter->getAddress()."<br /><button type='button' value='Get Direction' class='button' oncli

我得到下面的错误

错误

SyntaxError:属性列表后缺少}

内容:Al futaim,贸易公司

Saih Shuaib 3号36号M楼 -

PHP代码

$content=$servicecenter->getCompanyName()."<br />".$servicecenter->getAddress()."<br /><button type='button' value='Get Direction' class='button' onclick='closeInfoWindow(),calcRoute()' name='Get Direction'>Get Direction</button>"; 
$content=$servicecenter->getCompanyName()。“
”。$servicecenter->getAddress()。“
获取方向”;
脚本

var infowindow = new google.maps.InfoWindow({
  content:<?php echo $content; ?>;
});
var infowindow=new google.maps.infowindow({
内容:;
});
var infowindow=new google.maps.infowindow({
内容:
});
你不能有一个
。如果要分离属性,请使用


此外,根据您希望在那里回送的内容,您可能需要在php脚本周围添加

缺少内容的
引号,不需要
-

content: '<?php echo $content; ?>'
内容:“”

内容:

使用
json\u encode
并删除行尾的分号:

content: <?php echo json_encode($content); ?>  /* no ; here! */
content:/*否;此处*/

您需要添加引号(双引号或单引号均可)以添加更多信息:您需要添加引号(双引号或单引号均可),删除php结束标记后的分号,并记住转义输出(即尝试添加斜杠或htmlentities)添加引号SyntaxError:unterminated string literal content:它们不应该是双引号
,因为字符串中已经有单引号了吗?分号是首选项。有些人喜欢,有些人不喜欢。。。不能争辩使用。。。对不起,你的意思是在JavaScript中-是的,这将中断。在php代码中,它是可选的…@Svengali您不需要逃避您输出到浏览器的任何可能危险的内容吗?:)使用
json\u encode
生成JavaScript字符串比手动将引号插入更安全。在这种情况下,stdob的答案更好。这实际上是最好的解决方案。。。你不必关心它是如何输出的,它总是正确的;)直到删除分号看起来很可怕:)
content: <?php echo json_encode($content); ?>
content: <?php echo json_encode($content); ?>  /* no ; here! */