I am getting the below error.
Error
SyntaxError: missing } after property list
content:Al futaim, trading company
<br />
Building M, 36, Saih Shuaib 3 —
PHP code
$content=$servicecenter->getCompanyName()."<br />".$servicecenter->getAddress()."<br /><button type='button' value='Get Direction' class='button' onclick='closeInfoWindow(),calcRoute()' name='Get Direction'>Get Direction</button>";
Script
var infowindow = new google.maps.InfoWindow({
content:<?php echo $content; ?>;
});
I am getting the below error.
Error
SyntaxError: missing } after property list
content:Al futaim, trading company
<br />
Building M, 36, Saih Shuaib 3 —
PHP code
$content=$servicecenter->getCompanyName()."<br />".$servicecenter->getAddress()."<br /><button type='button' value='Get Direction' class='button' onclick='closeInfoWindow(),calcRoute()' name='Get Direction'>Get Direction</button>";
Script
var infowindow = new google.maps.InfoWindow({
content:<?php echo $content; ?>;
});
Share
Improve this question
edited Apr 1, 2016 at 10:42
Munawir
3,3569 gold badges35 silver badges51 bronze badges
asked Jul 31, 2015 at 10:09
Qaisar SattiQaisar Satti
2,7622 gold badges19 silver badges36 bronze badges
3
- 2 You need to add the quotes (either doulbe or single quotes will do) – Raphioly-San Commented Jul 31, 2015 at 10:12
- To add some more info: You need to add the quotes (either double or single quotes will do), remove the semicolon after the php closing tag and remember to escape your output (i.e. try addslashes or htmlentities) – Raphioly-San Commented Jul 31, 2015 at 10:18
- i got error after adding the quotes SyntaxError: unterminated string literal content: – Qaisar Satti Commented Jul 31, 2015 at 10:18
3 Answers
Reset to default 16Use json_encode
and delete the semicolon at end of line:
content: <?php echo json_encode($content); ?> /* no ; here! */
Missing the quote
s for content and no need of ;
-
content: '<?php echo $content; ?>'
OR
content: <?php echo json_encode($content); ?>
var infowindow = new google.maps.InfoWindow({
content:<?php echo $content; ?>
});
You can't have a ;
inside an object's declaration. If you want to separate properties, use ,
.
Also, depending on what you want to echo there, you might need to add "
around the php script.