i got a problem here .
I have this code to create the json data in locations.php
<?php
$locations = array(
array('2479 Murphy Court', "Minneapolis, MN 55402", "$36,000", 48.87, 2.29, "property-detail.html", "assets/img/properties/property-01.jpg", "assets/img/property-types/apartment.png"),
array('3398 Lodgeville Road', "Golden Valley, MN 55427", "$28,000", 48.866876, 2.309639, "property-detail.html", "assets/img/properties/property-02.jpg", "assets/img/property-types/apartment.png")
);
?>
<script type="text/javascript">
var locations = "<?= json_encode($locations) ?>";
</script>
I want to pass the json to locations.js . Which it will called by another .js file with getScript function. I tried to call the locations.php but its not working, so i create locations.js to test and it works
Not working
$.getScript("assets/php/locations.php", function(){
Working
$.getScript("assets/js/locations.js", function(){
locations.js
var locations = [
['2479 Murphy Court', "Minneapolis, MN 55402", "$36,000", 48.87, 2.29, "property-detail.html", "assets/img/properties/property-01.jpg", "assets/img/property-types/apartment.png"],
['3398 Lodgeville Road', "Golden Valley, MN 55427", "$28,000", 48.866876, 2.309639, "property-detail.html", "assets/img/properties/property-02.jpg", "assets/img/property-types/apartment.png"],
];
Can anyone help me? Thank you. Sorry for bad english and maybe hard to understand