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; ?>;
});
The "SyntaxError: missing ) after argument list" occurs when we make a syntax error when calling a function, e.g. forget to separate its arguments with a comma. To solve the error make sure to correct any syntax errors in the arguments list of the function invocation. Copied!
The JavaScript exception "missing ) after argument list" occurs when there is an error with how a function is called. This might be a typo, a missing operator, or an unescaped string.
Use 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With