I'm using Codeigniter4, and I generate a rather long JSON so that I can make map points with it. However, when I pass along the string with
echo view('pages/' . $page, $data);
And attempted to unpack the string on the html side with
var geojson = JSON.parse('<?php echo $geoJSON; ?>')
I get a syntax error because the entire json string was not sent. I have tested my setup with a smaller amount of data, so I am sure that the issue is the length of the string.
Is there any way to send large strings? If not, is there a better way? I have heard of something called AJAX, but MapBoxGL needs a json object with specific keys, so that is why I am passing along a complete json from my php side.